akhauriyash/Code-Regression huggingface dataset:
/***
* হে প্রভু আমাকে জ্ঞান দান করুন ।
***/
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;


int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n , a, b , c , d;
    cin >> n >> a>>b >> c >> d;
    --a, --b, --c, --d;
    string s;
    cin >> s;

    auto CanGo = [&](int from , int to){
        while(from < to){
            if(s[from + 1] == '.'){
                ++from;
            }
            else{
                if(s[from + 2] == '.'){
                    from += 2;
                }
                else{
                    return false;
                }
            }
        }
        return true;
    };
    auto Good = [&](int from, int to){
        for(int i = from; i <= to; i++){
            if(s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.'){
                return true;
            }
        }
        return false;
    };
    if(CanGo(a, c) && CanGo(b, d))
    if(c < d || Good(b, d)){
        cout << "Yes" << '\n';
        return 0;
    }
    cout << "No" << '\n';




    return 0;
}













Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  ll x;
  cin >> x;
  cout << x/11*2+(x%11+5)/6 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define um unordered_map
#define all(x) (x).begin(),(x).end()
#define forn(i,n) for(int i=0;i<int(n);++i)
#define for1(i,n) for(int i=1;i<=int(n);++i)
#define che(x) cout<<#x<<" having "<<x<<endl 
using namespace std;
typedef long double ld;typedef long long ll;
typedef vector<int> vi;typedef vector<pair<int, int>> vpi;typedef vector<vi> vvi;
typedef vector<ll> vll;typedef vector<pair<ll, ll>> vpll;typedef vector<vll> vvll;
template<class T>bool uin(T &a,T b){return a>b?(a=b,true):false;}
template<class T>bool uax(T &a,T b){return a<b?(a=b,true):false;}
const ll MOD=1e9+7,INF=1e18;
/********************************************************************************/
 

 
int32_t main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);
    cout.precision(10);cout<<fixed;
 
    int n; cin>>n;
    int a[n];
    forn(i,n) cin>>a[i];
    ld d=0;
    forn(i,n){
        d+=(1.0*1/a[i]);
    }
    ld ans=1.0*1/d;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  
  int count = 0;
  rep(i,s.size()){
    if(s[i] != t[i]) count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 4e5+10;
int n,a[MAXN];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	n*=3;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	long long ans = 0;
	for(int i=n-1;i>n/3;i-=2){
		ans += a[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1408
X = int(input())


def is_prime_number(number):
    is_dividable = lambda divided, divider: divided % divider == 0
    result = all([not is_dividable(number, divider) for divider in range(2, number)])

    return result


answer = X
while True:
    if is_prime_number(answer): break
    answer += 1

print(answer)


Measured memory_bytes: 3864
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	
	int nr = 1;
	
	while(k--)
	{
		if(nr == 1)
		{
			a /= 2;
			b += a;
		}
		else
		{
			b /= 2;
			a += b;
		}
		
		nr = 1 - nr;
		
	}
	
	cout << a << ' ' << b;
	
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

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

	string s;
	cin >> s;
	int len = s.length();
	if(s[len - 1] == 's') {
		cout << s << "es" << endl;
	}else {
		cout << s << "s" << endl;
	}
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll c1[]={539588932,729548371,700407153,404391958,962779130,184117322,927321758,444014759,542573865,237315285,417297686,471090892,183023413,660103155,727008098,869418286};
ll c0[]={0,765144583,346175634,347662323,5655049,184117322,927321758,444014759,542573865,237315285,417297686,471090892,183023413,660103155,727008098,869418286};
/*int solve(int n){
	ll ans=0;
	for(int s1=0; s1<=n; s1++){
		for(int s2=s1+1; s2+s1<=n; s2++){
			for(int n1=0; n1+s2+s1<=n; n1++){
				for(int n2=n1+1; n2+n1+s2+s1<=n; n2++){
					for(int u1=0; u1+n2+n1+s2+s1<=n; u1++){
						for(int u2=u1+1; u2+u1+n2+n1+s2+s1<=n; u2++){
							for(int k1=0; k1+u2+u1+n2+n1+s2+s1<=n; k1++){
								for(int k2=k1+1; k2+k1+u2+u1+n2+n1+s2+s1<=n; k2++){
									for(int e1=0; e1+k2+k1+u2+u1+n2+n1+s2+s1<=n; e1++){
										for(int e2=e1+1; e2+e1+k2+k1+u2+u1+n2+n1+s2+s1<=n; e2++){
											ans+=(s2-s1)*(n2-n1)*(u2-u1)*(k2-k1)*(e2-e1);
											ans%=MOD;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return ans;
}*/
int main()
{
	int t; cin>>t;
	while(t--){
		ll n; cin>>n;
		if(n%2==0){
			ll ans=0;
			ll p=1;
			for(int i=0; i<16; i++){
				(ans+=c0[i]*p)%=MOD;
				(p*=n)%=MOD;
			}
			cout<<ans<<endl;
		}else{
			ll ans=0;
			ll p=1;
			for(int i=0; i<16; i++){
				(ans+=c1[i]*p)%=MOD;
				(p*=n)%=MOD;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
    char s[100];
    int fl = 1;

    scanf("%s", s);

    for (int k = 0; s[k] != '\0'; k++ ) {
        //奇数
        if (k%2 == 0) {
            if (s[k] == 'L') {
                fl = 0;
            }
                
        }
        //偶数
        if (k%2 == 1) {
            if (s[k] == 'R') {
                fl = 0;
            }
        }

    }
    if (fl == 0) {
        puts("No");
    } else {
        puts("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[1010],sum;
int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n,less<int>());
  for(int i=0;i<k;i++) sum+=a[i];
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int p[200000],m[200000];
signed main(){
    int n,x,y;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        p[i]=x+y;
        m[i]=x-y;
    }
    sort(p,p+n);
    sort(m,m+n);
    cout<<max(p[n-1]-p[0],m[n-1]-m[0])<<endl;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;
    int64_t N, A, B;
    cin >> N >> A >> B;

    auto blue = (N / (A + B)) * A;
    auto total = (N / (A + B)) * (A + B);

    while (total < N)
    {
        if (total + A >= N)
        {
            blue += N - total;
            break;
        }
        total += (A + B);
        blue += A;
    }

    cout << blue << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a_ls = list(map(int, input().split()))
a_ls.sort()
class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod
 
    def combination(self, n, r):
        if n < r:
            return 0
        return self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod
 
    def permutation(self, n, r):
        return self.factorial(n) * self.invfactorial(n-r) % self.mod
 
    def factorial(self, i):
        return self.fac[i]
 
    def invfactorial(self, i):
        return self.invfac[i]
c = Combination(n)

ans = 0
for i in range(n-1,-1,-1):
    time_min = c.combination(n-i-1,k-1)
    time_max = c.combination(i,k-1)
    ans += time_max * a_ls[i]
    ans -= time_min * a_ls[i]
    '''
    print(time_min)
    print(i,k)
    print(time_max)
    print(ans)
    '''
    ans %= 10**9+7
print(ans)

Measured memory_bytes: 87960
#include<stdio.h>

int main(){

  int n;
  int i;
  int z;
  int x;
  int y;

  x = 1;
  y = 1;
 z = 1;
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n - 1 ; i++){
    
    z = x + y;
    
    x = y;
  
    y = z;
  }
 
  printf("%d\n",z);
  
  return 0;
}

Measured memory_bytes: 596
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

x,k,d=input2()
abs_x=abs(x)
count=min(abs_x//d,k) #移動回数
abs_x-=d*count #到達点
rem=k-count


if rem>0:
	if rem%2==1:
		abs_x-=d #abs_x>=0は自明なので，-でok

ans=abs(abs_x)
print(ans)

Measured memory_bytes: 9196
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

char solve(int n)
{
    long long tmp = 9;
    int len = 1;
    while(tmp * len < n){
        n -= tmp * len;
        tmp *= 10;
        ++ len;
    }

    int x = tmp / 9 + n / len;
    n %= len;

    ostringstream oss;
    oss << x;
    return oss.str()[n];
}

int main()
{
    for(;;){
        int n, k;
        cin >> n >> k;
        if(n == 0)
            return 0;

        for(int i=0; i<k; ++i)
            cout << solve(n-1+i);
        cout << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    vector<int> sum(n+1, 0);
    for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i-1];
    vector<int> lb;
    for(int i = 0; i+1 <= n; i++){
        for(int j = i+1; j <= n; j++){
            lb.push_back(sum[j]-sum[i]);
        }
    }
    sort(lb.begin(), lb.end());
    lb.erase(unique(lb.begin(),lb.end()), lb.end());
    int ans = 1<<30;
    for(int x : lb){
        vector<int> dp(n+1, 1<<30);
        dp[0] = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= i; j++){
                if(i == n && j == 1)    continue;
                if(sum[i]-sum[j-1] < x)   continue;
                dp[i] = min(dp[i], max(dp[j-1], sum[i]-sum[j-1]));
            }
        }
        ans = min(ans, dp[n]-x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3172
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=200005;

void solve()
{
    
    int n;
    cin>>n;
    int a[n];
    int x=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        x^=a[i];
    }
    for(int i=0;i<n;i++)
    {
        cout<<(x^a[i])<<" ";
    }
    cout<<endl;
    
    
    
    
    
}
int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}






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

int main(){
    int n;
    cin >> n;
    char s[n];
    int w[n+1] = {};
    for(int i = 0; i < n; i++) cin >> s[i];
    for(int i = 0; i < n; i++){
        if(s[i] == 'W') w[i+1] = w[i] + 1;
        else w[i+1] = w[i];
    }
    int min = n;
    for(int i = 0; i < n; i++){
        int num = w[i] + n-i-1-w[n]+w[i+1];
        if(min > num) min = num;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void) {
  ll n;
  scanf("%lld", &n);
  ll res = 0;
  for(ll i = 2; i <= 1000000; ++i) {
    int cnt = 0;
    while(n % i == 0) {
      n /= i;
      ++cnt;
    }
    int cur = 1;
    while(cnt >= cur) {
      cnt -= cur;
      ++cur;
    }
    res += cur-1;
  }
  if(n > 1) {
    ++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3204
#include <stdio.h>

int main(void) {
	int a, i;
	int num[100];

	scanf("%d", &a);

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

	for (i = a; i > 0; i--) {
		printf("%d", num[i]);
		if (i != 1) {
			printf(" ");
		}
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2688
#include<cstdio>
#include<algorithm>
#include<iostream>
#define N 200005
#define int long long
using namespace std;
int P,n,q,m;
long long Q,V[N],ans[N],a[N];
void CL(int x,long long v)
{
	int P;
	P=upper_bound(a+1,a+m+1,x)-a-1;
	if (!P)
	{
		ans[1]+=v;
		ans[x+1]-=v;
		return;
	}
	V[P]+=v*(x/a[P]);
	CL(x%a[P],v);
}
main()
{
	scanf("%lld%lld",&n,&q);
	m++;
	a[m]=n;
	for (int i=1;i<=q;i++)
	{
		scanf("%lld",&Q);
		while (m&&Q<=a[m])
			m--;
		a[++m]=Q;
	}
	V[m]=1;
	for (int i=m;i>1;i--)
	{
		V[i-1]+=V[i]*(a[i]/a[i-1]);
		CL(a[i]%a[i-1],V[i]);
	}
	ans[0]=0;
	ans[1]+=V[1];
	ans[a[1]+1]-=V[1];
	for (int i=1;i<=n;i++)
	{
		ans[i]+=ans[i-1];
		printf("%lld\n",ans[i]);
	}
	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

ll n,m;

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

	cin>>n>>m;
	if(m<2||(m<4&&n<0)) {
		cout<<'0'<<endl;
		return 0;
	}
	ll ans=0;

	if(2*n>m) ans+=m/2;
	else {
		ans+=n,m-=2*n;
		if(m>=4) ans+=m/4;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 22:12:15
*/

#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;
    cin >> a >> b;
    ll k;
    if(a%2 == b%2) cout << (max(a,b) + min(a,b))/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if (s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int r = 0;
  for(int i = 0; i < N;) {
    int pos = S.find("ABC", i);
    if(pos == -1) break;
    r++;
    i = pos + 1;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[105]={0};
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i&1 && a[i]&1)
            cnt++;
    }
    cout<<cnt<<endl;

}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath> 
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	int a[n+5],b[n+5];
	for(int i=0;i<n+1;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		if(b[i]>=a[i])
		{
			ans+=a[i];
			b[i]-=a[i];
			a[i]=0;
			if(b[i]>=a[i+1])
			{
				ans+=a[i+1];
				a[i+1]=0;
			}
			else
			{
				a[i+1]-=b[i];
				ans+=b[i];
			}
		}
		else
		{
			ans+=b[i];
			a[i]-=b[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi b(n);
  ll ans = 0;
  int prev = INF;
  rep(i,n-1) {
    cin >> b[i];
    ans += min(prev, b[i]);
    prev = b[i];
  }
  ans += b[n-2];
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;
int main() {
    int n;
    cin >> n;

    vector<int> inp(n);
    // vector<ll> x(n);
    // int _sum = 0;
    ll sum = 0;
    rep(i, 0, n) {
        cin >> inp[i];
        sum += inp[i];
        // if (i > 0) {
        //     sum[i] = sum[i - 1] + inp[i];
        // } else {
        //     sum[i] = inp[i];
        // }
        // cin >> x[i];
    }
    // vector<int> x(n);
    // x[0] = inp[0];
    // int ans = abs(_sum - 2 * x[0]);
    // ll ans = abs(_sum - 2 * x[0]);

    // rep(i, 1, n - 1) {
    ll ans = 100010001000;
    ll x   = 0;
    rep(i, 0, n - 1) {
        x += inp[i];
        // x[i] = x[i - 1] + inp[i];
        // if (abs(_sum - 2 * x[i]) < ans) {
        //     ans = abs(_sum - 2 * x[i]);
        // }
        // ans = min(ans, abs(_sum - 2 * x[i]));
        ans = min(ans, abs(sum - 2 * x));
    }

    // cout << ans << endl;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<vector<ll>> abc(n, vector<ll>(3));
	rep(i, n) {
		ll a, b, c;
		cin >> a >> b >> c;
		abc[i][0] = a, abc[i][1] = b, abc[i][2] = c;
	}
	//[kotae][sonotokitukattayatu]
	vector<vector<ll>> dp(n + 1, vector<ll>(3));

	rep(i, n)rep(j, 3)rep(k, 3) {
		if (j != k) {
			dp[i + 1][j] = max(dp[i][k] + abc[i][j], dp[i + 1][j]);
		}		
	}

	sort(all(dp[n]));

	dunk(dp[n][2]);

	return 0;
}

Measured memory_bytes: 11264
from itertools import product
n,a,b,c = map(int,input().split())
l = [int(input()) for i in range(n)]
x = list(product([0, 1, 2, 3], repeat=n))
ans = 10**10
for i in range(len(x)):
    if x[i].count(1) == 0 or x[i].count(2) == 0 or x[i].count(3) == 0:
        continue
    tmpa = 0
    tmpb = 0
    tmpc = 0
    for j in range(n):
        if x[i][j] == 1:
            tmpa += l[j]
        if x[i][j] == 2:
            tmpb += l[j]
        if x[i][j] == 3:
            tmpc += l[j]
    tmpans = abs(a-tmpa)+abs(b-tmpb)+abs(c-tmpc)
    tmpans += (x[i].count(1)-1)*10 + (x[i].count(2)-1)*10 + (x[i].count(3)-1)*10
    ans = min(ans,tmpans)
print(ans)

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

int main(){
  queue<int> q;
  int n,k,u,max=0;
  int g[101]={},c[101];
  int d[101][101]={};
  int di;
  cin>>n;
  for(int i=0;i<101;i++) c[i]=-1;
  c[1]=0;
  g[1]=1;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    if(max<k) max=k;
    for(int j=0;j<k;j++){
      cin>>di;
	d[u][j]=di;
    }
  }

  q.push(1);

  int a;
  while(!q.empty()){
 a=q.front();
    for(int i=0;i<=max;i++){

      if( d[a][i]>1 && g[d[a][i]]==0){
	g[d[a][i]]=1;
	q.push(d[a][i]);
	 c[d[a][i]]=c[a]+1;
      }
    }
      q.pop();
  }
  for(int i=1;i<=n;i++) cout<<i<<" "<<c[i]<<endl;
  return 0;
}

Measured memory_bytes: 1248
#include <stdio.h>
#define rep(i) for ((i) = 0;;(i)++)


int main(void) {
    char x[1001]; 
    int sum, i, k;
    while (1) {
        scanf("%s", x);
        if (x[0] == '0') break;
        sum = 0;
        rep(i) {
            if (x[i] == 0) break;
            sum += (x[i] - '0');
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2064
#include <iostream>
#include <string>

using namespace std;

string str;

int main(){
  cin >> str;
  char c = str[str.length()-1];
  if(c != 's'){
      for(int i=0 ; i<str.length() ; i++)
          cout << str[i];
      cout << "s";
  }
  else{

    for(int i=0 ; i<str.length() ; i++)
          cout << str[i];
      cout << "es";
  }

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	//string s[100], res = "";
	//int N, M;
	//int a[60], b[60], res[60] = { 0 };
	//string S;
	int N, M, X;
	int A[110];

	cin >> N >> M >> X;

	//int y = 700;
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
	}
	int mae = 0;
	int ushiro = 0;
	for (int i = 0; i < M; ++i) {	
		if (A[i] < X) {
			++mae;
		}
		else if (A[i] > X) {
			++ushiro;
		}
		//X -= m[i];
	}
	int res = min(mae, ushiro);
	/*
	sort(m, m + N);
	int res = N;
	res += X / m[0];
	*/

	//string res = "NO";
	/*
	if (A <= X && X <= (A + B)) {
		res = "YES";
	}
	*/
	cout << res << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n,int k) {
	//nのk桁目
	rep(i, k-1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N,M;
	cin >> N>>M;
	cout << N*(N-1)/2 + M*(M-1)/2;
}

Measured memory_bytes: 256
while True:
    a,b=map(int,input().split())
    if a ==0 and b==0:
        break
    for u in range(a):
        if u%2==0:
            for i in range(b):

                if i%2==0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        else:
            for e in range(b):
                if e%2==0:
                    print(".", end="")
                else:
                    print("#", end="")
            print()
    print()


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    map<int ,int> mp;
    rep(i,3){
        int x;  cin >> x;
        mp[x]++;
    }

    cout << mp.size() << endl;

    return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
#define MAX 10001
#define INF 2e8

struct node{
  int key;
  int weight;
  struct node *next;
};

typedef struct node *Node;
 
Node G[MAX];

Node cpy(int k,int w,Node n)
{
  Node x;
  
  x= (Node)malloc(sizeof(struct node));
  x->key = k;
  x->weight = w;
  x->next = n;
  
  return x;
}

void insert(int a,int b,int c)
{
  Node x;
  x=cpy(b,c,G[a]->next);
  G[a]->next=x;
}


int main()
{
  int i,j,n,count=0,u,k,v,c,color[MAX],d[MAX],pi[MAX],min,save;
  Node s;
 
  scanf("%d",&n);
  for(i=0; i<n; i++)
    G[i]=cpy(0,0,NULL);
    
  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d%d",&v,&c);
      insert(i,v,c);
    }
  }
  
  for(i=0; i<n; i++){
    color[i] = 0;
    pi[i] = -1;
    d[i] = INF;
  }
  d[0] = 0;
  
  while(1){
    min = INF;
    for(i=0; i<n; i++){
      if(color[i]!=2 && d[i]<min){
        min=d[i];
        save = i;
      }
    }
    if(min == INF)
        break;
    color[save]=2;
    
    for(s=G[save]; s!=NULL; s=s->next){
      if(color[s->key]!=2 && (s->weight+d[save])<d[s->key]){
	    pi[s->key] = save;
	    d[s->key] = s->weight+d[save];
    	color[s->key]=1;
      }
    }
  }
  for(i=0; i<n; i++)
    printf("%d %d\n",i,d[i]);
  
  return 0;
}
 




Measured memory_bytes: 17368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    ll N, M;
    cin >> N >> M;

    if(abs(N-M) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    ll a = 1, b=1;

    for(int i=2; i <= N; i++) {
        a *= i;
        a %= (ll)(1e9 + 7);
    }
    for(int i=2; i <= M; i++) {
        b *= i;
        b %= (ll)(1e9 + 7);
    }
    ll ans = (a * b) % (ll)(1e9 + 7);
    if (N == M) ans *= 2;
    ans %= (ll)(1e9 + 7);
    cout << ans << endl;

}

Measured memory_bytes: 3608
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	string ans = "Yes";
	ll n, a, b,t;
	in(n);

	vector<pair<ll, ll>> p(n);
	rep(i, 0, n) {
		in(a);
		in(b);
		p[i] = make_pair(b, a);
	}

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

	t = 0;
	rep(i, 0, n) {
		t += p[i].second;
		if (t > p[i].first) {
			ans = "No";
			break;
		}
	}

	outn(ans);

	return 0;

}


Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

s=input()
t=input()
ds=collections.defaultdict(set)
dt=collections.defaultdict(set)

for i in range(len(s)):
    ds[s[i]].add(t[i])
    dt[t[i]].add(s[i])

for si in ds.values():
    if len(si)>=2:
        print("No")
        exit()

for ti in dt.values():
    if len(ti)>=2:
        print("No")
        exit()

print("Yes")
# for i,e in d.items():
#     print(i,e)

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

int cnt_digits(ll N){
    int digits = 0;
    while(N > 0){
        N /= 10;
        digits++;
    }
    return digits;
}

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

    int ans = cnt_digits(N);

    for(ll A = 1LL; A*A <= N; A++){
        if(N % A != 0) continue;
        ll B = N / A;

        int cur = max(cnt_digits(A), cnt_digits(B));
        ans = min(ans, cur);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n;
signed main() {
	cin >> n;
	int ans = 1;
	rep(i, n) {
		int a; cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << endl;
}


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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int N = 1 << 9;
constexpr int W = 100000;

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

    std::vector<std::pair<int, int>> ps(n);
    for (auto& [v, w] : ps) std::cin >> v >> w;
    ps.emplace(ps.begin());

    auto dps = vec(N, vec(W + 1, 0));
    for (int i = 1; i < N && i <= n; ++i) {
        auto& dp = dps[i];
        dp = dps[i >> 1];

        auto [v, w] = ps[i];
        for (int x = W; x >= w; --x) {
            dp[x] = std::max(dp[x], dp[x - w] + v);
        }
    }

    int q;
    std::cin >> q;
    while (q--) {
        int i, wmax;
        std::cin >> i >> wmax;

        std::vector<std::pair<int, int>> qs;
        while (i >= N) {
            qs.push_back(ps[i]);
            i >>= 1;
        }

        const auto& dp = dps[i];

        int ans = 0, m = qs.size();
        for (int b = 0; b < (1 << m); ++b) {
            int wsum = 0, vsum = 0;
            for (int j = 0; j < m; ++j) {
                if ((b >> j) & 1) continue;
                auto [v, w] = qs[j];
                wsum += w, vsum += v;
            }

            if (wsum > wmax) continue;
            ans = std::max(ans, vsum + dp[wmax - wsum]);
        }

        std::cout << ans << "\n";
    }
}

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

    solve();

    return 0;
}


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

typedef long long int   ll;
#define int             ll
#define PI              3.1415926535897932384626433832795

#define pb              push_back
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]

#define hell            freopen("input.txt","r", stdin);freopen("output.txt", "w", stdout);freopen("error.txt", "w",stderr);
#define fastasF_boi()   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
//#define cerr            if(false)cerr

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
int mulmod(int a,int b){return ((a%mod)*(b%mod))%mod;}
int addmod(int a,int b){return (((a%mod)+(b%mod))+mod)%mod;}

void solve(){
    int h,w;cin>>h>>w;
    int m;cin>>m;
    string s[h];
    vector<int> r(h,0),c(w,0);
    set<pair<int,int>> st;
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        x--;y--;
        st.insert({x,y});
        r[x]++;
        c[y]++;
    }
    vector<int> ri,ci;
    int mx=0;
    for(int i=0;i<h;i++){
        if(r[i]==mx)
            ri.push_back(i);
        else if(r[i]>mx){
            ri.clear();
            ri.push_back(i);
            mx=r[i];
        }
    }
//    cout<<"mx:"<<mx<<endl;
//    cout<<"ri : "; for(auto it:ri) cout<<it<<" "; cout<<endl;
    mx=0;
    for(int i=0;i<w;i++){
        if(c[i]==mx)
            ci.push_back(i);
        else if(c[i]>mx){
            ci.clear();
            ci.push_back(i);
            mx=c[i];
        }
    }
//    cout<<"mx:"<<mx<<endl;
//    cout<<"ci : "; for(auto it:ci) cout<<it<<" "; cout<<endl;
    int ans=0;
    for(int i=0;i<ri.size();i++){
        for(int j=0;j<ci.size();j++){
//            cout<<ri[i]<<","<<ci[j]<<endl;
//            cout<<r[ri[i]]<<","<<c[ci[j]]<<endl;
            int cur=r[ri[i]]+c[ci[j]];
//            cout<<cur<<endl;
            if(st.find({ri[i],ci[j]})==st.end()){
                ans=cur;
                cout<<ans<<endl;
                return;
            }else {
                ans=cur-1;
            }
        }
    }
    cout<<ans<<endl;
}

signed main(){
//    hell;

    fastasF_boi();
    int t=1;
//    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
}



Measured memory_bytes: 44412
def bom(X,Y,point):
    point[Y][X]="0"
    for x,y in [[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:
        if 0<=X+x<8 and 0<=Y+y<8 and point[Y+y][X+x]=="1":bom(X+x,Y+y,point)
    return point

for i in range(int(input())):
    input()
    point=[list(input()) for _ in [0]*8]
    X=int(input())-1
    Y=int(input())-1
    print("Data "+str(i+1)+":")
    answer=bom(X,Y,point)
    answer_box=[]
    for i in range(8):
        p=""
        for j in range(8):
            p +=answer[i][j]
            if j==7:
                answer_box.append(p)
    for k in range(8):
        print(answer_box[k])


Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
int a,b;
cin>>a>>b;
int d=a/2;
d++;
for(int c=0;c<a-1;c++){
    if(d>c)printf("0 ");
    else printf("%d ",b);
    }
    printf("%d\n",b);
}

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

int main(){
	int p, q, r;
	cin >> p >> q >> r;
	if (p >= q && p >= r){
		cout << q + r << endl;
    }
	else if (q >= p && q >= r){
		cout << p + r << endl;
    }
	else{
		cout << p + q << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
//typedef long long ll;
//typedef pair<ll, ll> l_l;
//typedef pair<int, int> i_i;
int main(){
int n;
vector <int> a(n+1);
cin>>n;
rep(i,n){
  int temp;
  cin>>temp;
  a[temp-1]=i+1;
}
rep(i,n){
  cout<<a[i]<<' ';;
}
}


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


int main()
{
    int n,m,k;
    cin>>n>>m>>k;

    int a[n+1],b[m+1];
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int i=1;i<=m;i++) cin>>b[i];


    long long A[n+1],B[m+1];
    A[0]=0; B[0]=0;

    for(int i=1;i<=n;i++)
        A[i] = A[i-1] + a[i];

    for(int i=1;i<=m;i++)
    {
        B[i]= B[i-1] + b[i];
    }

    int mx = -1;
    for(int i=0;i<=n;i++)
    {
        if(A[i]>k)
            break;

        int left = 0, right = m;
        while(left<=right)
        {
            int mid = (left + right)/2;
            if(A[i] + B[mid]<=k)
            {
                mx = max(mx, mid + i);
                left = mid+1 ;
            }
            else
            {
                right = mid - 1;
            }
        }



    }

    cout<<mx<<endl;

}


Measured memory_bytes: 8280
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int n,m;
int a[100010];
vector<int> tree[100010];
vector<int> G[100010];
bool v[100010];
void dfs(int i,int p,int id){
    tree[id].push_back(a[i]);
    v[i]=true;
    for(auto e:G[i]){
        if(e==p)continue;
        if(v[e])continue;
        dfs(e,i,id);
    }
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int id=0;
    if(m==n-1){
        cout<<0<<endl;
        return 0;
    }
    if(n<2*(n-m-1)){
        cout<<"Impossible"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(!v[i]){
            dfs(i,-1,id);
            id++;
        }
    }
    int c=2*(n-m-1);
    ll ans=0;
    priority_queue<int> q;
    for(int i=0;i<id;i++){
        sort(all(tree[i]));
        ans+=tree[i][0];
        c--;
        for(int j=1;j<tree[i].size();j++){
            q.push(-tree[i][j]);
        }
    }
    while(c--){
        ans-=q.top();q.pop();
    }
    cout<<ans<<endl;
}


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

int main() {
    int n;
    cin >> n;
    int a[100] = {};
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        int j = i - 1;
        int v = a[i];
        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j + 1] = v;
        for (int k = 0; k < n; k++) {
            if (k) cout << " ";
            cout << a[k];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
const int N=15;
struct node
{
    int a[N];
    int k;
}b[N];
int s[N];
int n,m;
int judge(int p)
{
    //printf("p=%d\n",p);
    int tmp[N];
    memset(tmp,0,sizeof(tmp));
    int j=1;
    while(p>0)
    {
        tmp[j]=p%2;
        p=p/2;
        j++;
    }
    /*
    for(int i=1;i<=n;i++)
        printf("%d ",tmp[i]);
    printf("\n");
    */
    int flag=0;
    for(int i=1;i<=m;i++)
    {
        int cou=0;
        for(int j=1;j<=b[i].k;j++)
        {
            //printf("+ %d %d %d\n",b[i].a[j],tmp[b[i].a[j]],s[i]);
            if(tmp[b[i].a[j]]==1)
            {
                cou++;
            }
        }
        if(cou%2==s[i])
            flag++;
    }
    if(flag==m)
        return 1;
    else
        return 0;
    //return flag;
}
int main()
{

    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&b[i].k);
        for(int j=1;j<=b[i].k;j++)
            scanf("%d",&b[i].a[j]);
    }


    for(int i=1;i<=m;i++)
        scanf("%d",&s[i]);
    int p=pow(2,n);
    int ans=0;
    for(int i=0;i<=p-1;i++)
    {
        int tmp=judge(i);
        ans+=tmp;
    }
    printf("%d\n",ans);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	m := make(map[int]int)
	for i := 1; i <= N; i++ {
		m[i] = 0
	}
	for i := 0; i < K; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var a int
			fmt.Scan(&a)
			m[a]++
		}
	}
	ans := 0
	for _, v := range m {
		if v == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2472
#include<iostream>

using namespace std;

int main()
{
  while(1)
  {
    int n;
    int table[1001][5];
    cin >> n;
    if(!n)
      break;
    for(int i = 0; i < n; i++)
    {
      cin >> table[i][0] >> table[i][1] >> table[i][2] >> table[i][3];
      table[i][4] = table[i][1] * 4 + table[i][2] * 9 + table[i][3] * 4;
    }
    int lim[5];
    bool b = true;
    cin >> lim[1] >> lim[2] >> lim[3] >> lim[4];
    for(int i = 0; i < n; i++)
    {
      bool f = true;
      for(int j = 1; j < 5; j++)
      {
       	if(table[i][j] > lim[j])
	{
          f = 0;
          break;
	}
      }
      if(f)
      {
       	cout << table[i][0] << endl;
	b = 0;
      }
    }
    if(b)
      cout << "NA" << endl;
  }
}

Measured memory_bytes: 1180
/*
 * 17-2-18_ARC069_A.cpp
 *
 *  Created on: 2017/02/18
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>

using namespace std;

long long N,M;
long long ans;
int main(){
	cin >> N >>M;
	ans = min(N,M/2);
	N -= ans;
	M -= 2*ans;
	ans += M/4;
	cout << ans << endl;
	return 0;
}




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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll n; cin >> n;
    vector<ll> p(n); rep(i, n){cin >> p.at(i);}
    ll cnt = 0;
    rep(i, n - 2){
        vector<ll> tmp; rep(j, 3){tmp.push_back(p[i+j]);}
        sort(tmp.begin(), tmp.end());
        auto iter = lower_bound(tmp.begin(), tmp.end(), p[i+1]);
        if (iter - tmp.begin() == 1){cnt++;}
    }
    cout << cnt << endl;
}

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


Measured memory_bytes: 256
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_


int main() {

    int R, G, B, N;
    std::cin >> R >> G >> B >> N;
    int ans = 0;
    for (int r = 0; r <= N / R; ++r) {
        for (int g = 0; g <= N / G; ++g) {
            int dif = N - r * R - g * G;
            if ((dif >= 0) && (dif % B == 0)) {
                ++ans;
            }
        }
    }
    std::cout << ans << std::endl;

}

Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())
if a*a*b<=x*2:
    c=2*(a*a*b-x)/(a*a*a)
    print(math.degrees(math.atan(c)))
else:
    c = (a*b*b)/(2*x)
    print(math.degrees(math.atan(c)))

Measured memory_bytes: 3060
n = int(input())
a = [int(input()) for _ in range(n)]

left = [0] * n
for i in range(n):
    if i == 0:
        left[i] = a[i]
    else:
        left[i] = max(left[i - 1], a[i])

right = [0] * n
for i in range(n - 1, -1, -1):
    if i == n - 1:
        right[i] = a[i]
    else:
        right[i] = max(right[i + 1], a[i])

for i in range(n):
    if i == 0:
        print(right[1])
    elif i == n - 1:
        print(left[n - 2])
    else:
        print(max(left[i - 1], right[i + 1]))


Measured memory_bytes: 15656
#include<stdio.h>

#define NMAX 100

void insertionSort(int[], int);
void output (int[], int);

int main(){

  int N, i;
  int A[NMAX];

  scanf("%d", &N);

    for(i = 0; i < N; i++){

      scanf("%d", &A[i]);
    }
    
    output(A, N);
    insertionSort(A, N);
      
  return 0;
}

void insertionSort(int A[], int N){

  int v, i, j;

  for(i = 1; i < N; i++){

    v = A[i];
    j = i - 1;

    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;   
    }

    A[j + 1] = v;
    output(A, N);
  }
}

void output(int A[], int N){

  int i;

  for(i = 0; i < N; i++){

    if(i > 0)
      printf(" ");
    printf("%d",A[i]);
  }
  
  printf("\n");
}

  



Measured memory_bytes: 2072
A,B,C = map(int,input().split())

if (A == B) and ((B != C) and (A != C)) :
    print("Yes")
elif (B == C) and ((C != A) and (B != A)):
    print("Yes")
elif (C == A) and ((A != B) and (C != B)) :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3064