akhauriyash/Code-Regression huggingface dataset:
for line in open(0).readlines():
    a, b, c, d, e, f = map(int, line.split())
    det = a*e - b*d
    x = (e*c - b*f)
    y = (a*f - d*c)
    if det < 0:
        x = -x; y = -y; det = -det
    print("%.03f %.03f" % (x/det, y/det))



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

int main(){
	string s;
	int a,b;
	cin>>a>>b;
	cin>>s;
	if(s.size()!=a+b+1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0; i<s.size(); i++){
		if(i!=a){
			if(!isdigit(s[i])){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(s[i]!='-'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    m[s]++;
  }
  vector<string> v = {"AC", "WA", "TLE", "RE"};
  for (auto &i : v) {
    cout << i << " x " << m[i] << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) (int)a.size()
#define fi first
#define se second
#define ar array

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int > pii;
const ll MOD =1e9+7;


void solve(){
	int n; cin >> n;
	ll s=0;
	for(int i = 0; i < n; ++i){
		int x; cin >> x;
		s += (x-1);
	}
	cout << s;
}

int main(){
	int t=1;
	//cin >> t;
	while(t--){
		solve();
		cout <<'\n';
	}
}


Measured memory_bytes: 3632
#include<stdio.h>

int main() {
  int n;
  char str[105];
  scanf("%d", &n);
  scanf("%s", str);
  if (n%2==1) {
    printf("No\n");
  } else {
    int idx = n / 2;
    int isValid = 1;
    for(int i=0; i<idx; i++) {
      if (str[i] != str[i+idx]) isValid = 0;
    }
    if (isValid) puts("Yes");
    else puts("No");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define iinf 0x3f3f3f3f
#define linf (1ll<<60)
#define eps 1e-8
#define maxn 1000010
#define maxe 1000010
#define cl(x) memset(x,0,sizeof(x))
#define rep(i,a,b) for(i=a;i<=b;i++)
#define drep(i,a,b) for(i=a;i>=b;i--)
#define em(x) emplace(x)
#define emb(x) emplace_back(x)
#define emf(x) emplace_front(x)
#define fi first
#define se second
#define de(x) cerr<<#x<<" = "<<x<<endl
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll read(ll x=0)
{
	ll c, f(1);
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+c-0x30;
	return f*x;
}
ll f[30][10], g[30], sg[30];
ll verybig = 2e5;
ll ans[maxn];
int main()
{
	ll k = read(), n, i, j, N=15;
	rep(i,0,9)f[1][i]=1;
	g[1]=9;
	sg[1]=9;
	rep(i,2,N)
	{
		rep(j,0,9)
		{
			if(j+1<=9)f[i][j]+=f[i-1][j+1];
			if(j-1>=0)f[i][j]+=f[i-1][j-1];
			f[i][j]+=f[i-1][j];
			// if(i<=3)printf("f[%lld][%lld]=%lld\n",i,j,f[i][j]);
			// f[i][j]=min(f[i][j],verybig);
		}
		rep(j,1,9)g[i]+=f[i][j];
		sg[i]=sg[i-1]+g[i];
		// g[i]=min(g[i],verybig);
		// printf("i=%lld g=%lld sg=%lld\n",i,g[i],sg[i]);
	}
	rep(n,1,15)if(sg[n]>=k)break;
	// printf("n=%lld\n",n);
	k -= sg[n-1];
	// printf("k=%lld\n",k);
	drep(i,n,1)
	{
		ll a, b;
		if(i==n)a=1, b=9;
		else a=max(0ll,ans[i+1]-1), b=min(9ll,ans[i+1]+1);
		// printf("i=%lld a=%lld b=%lld\n",i,a,b);
		rep(j,a,b)
		{
			// printf("	j=%lld f=%lld k=%lld\n",j,f[i][j],k);
			if(f[i][j]<k)k-=f[i][j];
			else break;
		}
		ans[i]=j;
		putchar(j+0x30);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n, k);
	vector<int> a(n);
	cin >> a;
	
	inc(t, k) {
		bool f = true;
		RF(e, a) { if(e < n) { f = false; } }
		if(f) { break; }
		
		vector<int> s(n + 1);
		inc(i, n) {
			s[max(0, i - a[i])]++;
			s[min(n, i + a[i] + 1)]--;
		}
		inc(i, n) { s[i + 1] += s[i]; }
		s.pop_back();
		a = s;
	}
	OUT(a);
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll N,A,B,K;
    cin >> N >> A >> B >> K;
    COMinit();
    ll ans=0;
    rep(i,N+1){
        ll sum=K-A*i;
        if (sum<0||sum%B!=0){
            continue;
        }
        ll j=sum/B;
        ans+=COM(N,i)*COM(N,j)%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12288
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cerr << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD=1e9+7,INV=500000004;
deque<ll> dp[200005],tag[200005];
vector<ll> G[200005];
ll w[200005],two[200005];

ll pw(ll a,ll n)
{
	ll re=1;
	for(a%=MOD;n;n>>=1,a=a*a%MOD)
		if(n&1) re=re*a%MOD;
	return re;
}

void dfs(ll u)
{
	ll mx=u,sx=0,r=1;
	vector<ll> p,m;
	w[u]=1;
	for(ll i:G[u])
	{
		dfs(i),w[u]+=w[i]; 
		if(dp[i].size()>dp[mx].size()) sx=dp[mx].size(),mx=i;
		else if(dp[i].size()>sx) sx=dp[i].size();
	}
	//cout << u << ":\n";
	p.resize(sx,0),m.resize(sx,1);
	for(ll i:G[u])
		if(i!=mx)
		{
			dp[i].resize(sx,0),r=r*two[w[i]]%MOD;
			for(ll j=0,t=1;j<sx;++j)
			{
				if(j<tag[i].size()) t=t*tag[i][j]%MOD;
				dp[i][j]=dp[i][j]*t%MOD;
				p[j]=(p[j]+dp[i][j]*pw(two[w[i]]-dp[i][j]+MOD,MOD-2))%MOD,m[j]=m[j]*(two[w[i]]-dp[i][j]+MOD)%MOD;
			}
		}
	if(tag[mx].size()<=sx)
		tag[mx].resize(sx+1,1);
	for(ll i=0,t=1;i<sx;++i)
	{
		if(i<tag[mx].size()) t=t*tag[mx][i]%MOD,r=r*tag[mx][i]%MOD,tag[mx][i]=1;
		dp[mx][i]=dp[mx][i]*t%MOD;
		dp[mx][i]=(two[w[mx]]-dp[mx][i]+MOD)*m[i]%MOD*(p[i]+dp[mx][i]*pw(two[w[mx]]-dp[mx][i]+MOD,MOD-2)%MOD)%MOD;
	}
	dp[u].swap(dp[mx]),tag[u].swap(tag[mx]);
	tag[u][sx]=tag[u][sx]*r%MOD;
	dp[u].push_front(two[w[u]-1]*INV%MOD),tag[u].push_front(2);
	while(tag[u].size()>dp[u].size()) tag[u].pop_back();
	//DB(dp[u],0,dp[u].size())
	//DB(tag[u],0,tag[u].size())
	//cout << "**" << sx << "\n";
}

int main()
{jizz
	ll n,x,ans=0;
	cin >> n,two[0]=1;
	for(int i=1;i<=n;++i)
		cin >> x,G[x].pb(i),two[i]=(two[i-1]<<1)%MOD;
	dfs(0);
	for(ll i=0,t=1;i<dp[0].size();++i)
	{
		if(i<tag[0].size()) t=t*tag[0][i]%MOD;
		ans=(ans+dp[0][i]*t)%MOD;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 381552
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int a, mn=n, ma=0;
  bool ans;
  map<int, int> m;
  REP(i, n){
    cin>>a;
    mn=min(mn, a);
    ma=max(ma, a);
    ++m[a];
  }
  if(ma-mn>1) {
    ans=false;
  }
  else if(mn==ma){
    if(ma==n-1) ans=true;
    else if(n<4 && ma==1) ans=true;
    else if(n>=4 && ma<=n/2) ans=true;
    else ans=false;
  }
  else{
    if(m[ma]<2) ans=false;
    else if(ma>m[mn] && ma<=m[ma]/2+m[mn]) ans=true;
    else ans=false;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;


int main()
{
    long long int a,b;
    while(scanf("%lld %lld",&a,&b)!=EOF)
    {
        if(a<0)
        {
            if(b>=0)
                printf("Zero\n");
            else if((b-a)%2==0)
                printf("Negative\n");
            else
                printf("Positive\n");
        }
        else if(a==0)
            printf("Zero\n");
        else
            printf("Positive\n");
    }

}

Measured memory_bytes: 256
def main(x: int, y: int):
    award = 0

    if x == y == 1:
        award += 400000

    for i in [x, y]:
        if i == 1:
            award += 300000
        elif i == 2:
            award += 200000
        elif i == 3:
            award += 100000

    print(award)


if __name__ == "__main__":
    x, y = map(int, input().split())

    main(x, y)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{   int n,k;
    cin>>n>>k;
    int a[n],dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){cin>>a[i];dp[a[i]]=1;}
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i>a[j]&&dp[i-a[j]]==0)
                dp[i]=1;
        }
    }
    (dp[k])?cout<<"First":cout<<"Second";


}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;




int main(void){
    string s(3,'0');
    cin >> s; 
    int c=count(all(s),'A');
    if(c==0 || c==3){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
# ABC086-C

awk '
BEGIN {
    t = 0; x = 0; y = 0
    ans = "Yes"
}
(NF >= 3) {
    dt = $1 - t; dx = $2 - x; dy = $3 - y
    if (dx < 0) { dx = -dx }
    if (dy < 0) { dy = -dy }
    if (dx + dy > dt || (dx + dy) % 2 != dt % 2) {
        ans = "No"
        exit
    }
    t = $1; x = $2; y = $3
}
END { print ans }
'


Measured memory_bytes: 1696
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    D, G = map(int, input().split())
    pc = [tuple(map(int, input().split())) for _ in range(D)]

    ans = 10 ** 9
    for i in range(2 ** D):
        sum_v = 0
        cnt = 0
        for j, (p, c) in enumerate(pc):
            if i & 1 << j:
                sum_v += (j+1) * 100 * p + c
                cnt += p
        if sum_v >= G:
            if cnt < ans:
                ans = cnt
            continue
        for j, (p, c) in enumerate(pc[::-1]):
            k = D - j
            if (i & 1 << k-1) == 0:
                for _ in range(p):
                    sum_v += k * 100
                    cnt += 1
                    if sum_v >= G:
                        if cnt < ans:
                            ans = cnt
                        break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;

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

        int N = sc.nextInt();
        int tmp = N;
        int sum = 0;
        int[] nums = {100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};

        for (int num : nums) {
            sum += tmp / num;
            tmp = tmp % num;
        }

        System.out.println(N % sum == 0 ? "Yes" : "No");
    }
}



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

int main(){
  int N;
  unordered_map<char,int> dict{{'M',0},{'A',0},{'R',0},{'C',0},{'H',0}};
  cin >> N;
  string S;
  for(int i = 0; i < N;++i){
    cin >> S;
    if(S[0] == 'M') ++dict['M'];
    else if(S[0] == 'A') ++dict['A'];
    else if(S[0] == 'R') ++dict['R'];
    else if(S[0] == 'C') ++dict['C'];
    else if(S[0] == 'H') ++dict['H'];
  }
  long long answer = 0;
  for(string pattern : {"MAR","MAC","MAH","MRC","MRH","MCH","ARC","ARH","ACH","RCH"}){
    long long temp = 1;
    for(int i = 0; i < pattern.size();++i){
      temp *= dict[pattern[i]];
    }
    answer += temp;
  }
  cout << answer << endl;
}

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

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin>>n;
	if (n == 1) cout<<"Hello World\n";
	else{
		int a, b; cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int m, i, j, k, n, c, count, flag;
    int a[100];
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    i = 0;
    flag = 1;
    while(flag != 0){
        flag = 0;
        for(j = n -1; j > i; j--){
            if(a[j] < a[j-1]){
                c = a[j];
                a[j] = a[j-1];
                a[j-1]  = c;
                count++;
                flag = 1;
            }
        }
        i++;
    }
    
    printf("%d", a[0]);
    for(k = 1; k < n; k++){
        printf(" %d", a[k]);
    }
    printf("\n");
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
map<char,int>m;
int main()
{
    int i,cc,j;
    char c[100000];
    while(cin>>c)
    {
        cc=0;
        for(i=0;i<strlen(c);i++)
        {
            m[c[i]]++;
        }
        for(i=0;i<strlen(c);i++)
        {
            if(m[c[i]]%2!=0)
               {
                   cout<<"No"<<endl;
                    return 0;

               }
            else
            {
                cc++;

            }
        }
        if(cc==strlen(c))cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    int ma=a[0]+a[1];
    for(int i=2;i<N;i++)
    {
        int t=a[i-2]+a[i-1]+a[i];
        if(t>ma)ma=t;
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 3984
def solve():
    W,H,N = map(int, input().split())
    xl,xr = 0,W
    yl,yr = 0,H
    for _ in range(N):
        x,y,a = map(int, input().split())
        if a == 1:
            xl = max(xl, x)
        elif a == 2:
            xr = min(xr, x)
        elif a == 3:
            yl = max(yl, y)
        elif a == 4:
            yr = min(yr, y)
    
    print((xr-xl)*(yr-yl) if xr-xl > 0 and yr-yl > 0 else 0)
    
solve()

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x;
    cin >> x;
    int c500 = x / 500;
    x -= c500 * 500;
    int c5 = x / 5;
    int ans = c500 * 1000 + c5 * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.split().map(&:to_i)
a= gets.split().map(&:to_i)
b = gets.split().map(&:to_i)
c= gets.split().map(&:to_i)
sum = 0
prev = 99999
a.each do |x|
  sum += b[x-1]
  if prev+1 == x
    sum += c[x-2]
  end
  prev = x
end
puts sum

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
	int N;
 	scanf("%d", &N);
  	if(N == 111) printf("999\n");
  	else if(N == 119) printf("991\n");
  	else if(N == 191) printf("919\n");
  	else if(N == 199) printf("911\n");
  	else if(N == 911) printf("199\n");
  	else if(N == 919) printf("191\n");
  	else if(N == 991) printf("119\n");
  	else if(N == 999) printf("111\n");
  	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
     string S,T;
     cin >> S >> T;
     bool ans = false;
     for(int i = 0; i < S.size(); i++){
          if(S == T) ans = true;
          S = S.back() + S;
          S.pop_back();
     }
     if(ans) cout << "Yes" << endl;
     else cout << "No" << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v.at(i);
    }
    int count=0;
    int m=0;
    int ans=-1;
    for(int j=0;j<=n;j++){
        count++;
        if(v.at(m)==2){
            ans=count;
            break;
        }
        m=v.at(m)-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let [a,b]=t.s(2)
  let c=[],d=[],l=1001
  for(let i=0;i<a;i++){
    c.push(t.n())
    d.push(t.n())
  }
  for(let i=0;i<a;i++){
    if(d[i]<=b&&l>c[i]){
      l=c[i]
    }
  }
  t.o(l==1001?'TLE':l)
}
main()

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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int res = h[0];
  for (int i = 1; i < n; i++) {
    res += max(h[i] - h[i-1], 0);
  }
  cout << res << endl;
  return 0;
} 

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        ll a,b,c;
        cin>>a>>b>>c>>k;
        if(k<=a+b)
        {
            cout<<min(a,k);
            return 0;
        }
        k=k-(a+b);
        cout<<a-k;
    }
    return 0;
}

Measured memory_bytes: 3648
/*
*@Author  Chand Vachhani
*/

#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define mii         map<int,int>
#define pb          push_back
#define pf          push_front
#define mp(a,b)          make_pair((a),(b))
#define vpii        vector<pair<int,int>>
#define fo(i,l,n)   for(int i{l}; i<n; i++)
#define rf(s)       for(auto &c : s)
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define PI          3.141592653589
#define sz(x)       (int)x.size()
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007  

using namespace std;

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

signed main(){
    tezz
    
    string s;
    cin >> s;
    string ss[7]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
    fo(i,0,7){
        if(s==ss[i]){
            cout << i+1 << endl;
            return 0;
        }
    }
    
    return 0;
}   






















Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		vector<int> r(n), w(n);
		rep(i,n){
			cin >> r[i] >> w[i];
		}
		auto it = max_element(all(r));
		int maxi = distance(r.begin(), it);

		int sum = accumulate(all(r),0);
		int cnt = 0;

		if(sum - *it < *it){
			int s = *it * 2 - sum;
			vector<bool> dp(s + 1,0);
			dp[0] = 1;
			rep(i,n){
				if(maxi == i) continue;
				for(int j = s; j >= w[i]; j--){
					if(dp[j - w[i]]) dp[j] = true;
				}
			}

			for(int i = s; i >= 0; i--) {
				if(dp[i]) {
					cnt = s - i;
					break;
				}
			}
			//rep(i,it->first + 1){ cout << dp[i] << ' '; } cout << endl;
		}
		cout << accumulate(all(r),0) + accumulate(all(w),0) + cnt << endl;
	}
}

Measured memory_bytes: 3080
import math
while True:
    n=int(input())
    if n==0:
        break
    s=list(map(int,input().split()))
    m=sum(s)/len(s)
    a=0
    for i in range(n):
        a+=(s[i]-m)**2
    b=math.sqrt(a/n)
    print('{:.5f}'.format(b))


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

int main () {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] == a[2]) {
cout <<"Yes"<< endl;
}
else {
cout << "No" << endl;
}
}

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


def read():
    S = input().strip()
    T = input().strip()
    return S, T


def solve(S, T, INF = 100000):
    S = '.' + S
    T = '.' + T
    dp = [[INF for j in range(len(T))] for i in range(len(S))]
    
    offset = -1
    for i in range(len(S)):
        dp[i][0] = 0
    for j in range(len(T)):
        dp[0][j] = 0
    for i in range(1, len(S)):
        for j in range(1, len(T)):
            if S[i] == '?' or T[j] == '?' or S[i] == T[j]:
                dp[i][j] = dp[i-1][j-1] + 1
                if dp[i][j] == len(T)-1:
                    offset = i - (len(T)-1)
            else:
                dp[i][j] = 0
    
    if offset == -1:
        return 'UNRESTORABLE'
    U = [s if s != '?' else 'a' for s in S[1:]]
    for i in range(len(T)-1):
        U[offset + i] = T[i+1]
    return ''.join(U)
            

if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 3192
#include <stdio.h>
#include <stdlib.h>
int main(int argv, char *argc[]){
    int num;
    int x;
    long max, min, sum=0;
        
    scanf("%d", &num);
    long array[num];
    
    for(x=0; num>x; x++){
        scanf("%ld", &array[x]);
        
    
        sum += array[x];
        
        if((max < array[x]) || (0 == x)) max = array[x];
        if((min > array[x]) || (0 == x)) min = array[x];
    }
    
    printf("%ld %ld %ld\n", min, max, sum);
    
    return 0;
}

Measured memory_bytes: 676
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;

  cin >> n;

  int maxval = 0;
  int minval = INF;

  while(n--){
    int x;
    cin >> x;
    maxval = max(maxval, x);
    minval = min(minval, x);
  }

  cout << maxval - minval << endl;

  return 0;
}


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

int main()
{
    int n, m;

    cin >> n >> m;

    char a[m][n];
    int s[m];

    for( int i = 0; i < m; i++ )
        s[i] = 0;

    for( int i = 0; i < m; i++ )
    {
        for( int j = 0; j < n; j++ )
        {
            cin >> a[i][j];
            if( a[i][j] == 'W' )
                s[i]++;
        }
    }

    int x = 0, error = 0;
    for( int i = 0; i < m; i++ )
        error += s[i];
    
    int w[m], e[m];
    for( int i = 0; i < m; i++ )
    {
        w[i] = 0;
        e[i] = 0;
    }

    for( int j = 0; j < n; j++ )
    {

        int sum = 0;
        for( int i = 0; i < m; i++ )
        {
            if( a[i][j] == 'W' )
                w[i]++;
            else
                e[i]++;

            sum += e[i] + s[i] - w[i];
        }

        if( sum < error )
        {
            error = sum;
            x = j + 1;
        }
    }

    cout << x << " " << x + 1 << endl;

    return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int m,d;
  cin>>m>>d;
  int cnt = 0;
  FOR(i,1,m+1)FOR(j,22,d+1) {
    auto ds = to_string(j);
    int d10 = ds[0] - '0';
    int d1 = ds[1] - '0';
    if (d1 < 2) continue;
    if (i == d10 * d1) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}


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

signed main(void)
{
	int n, H;
	cin >> n;
	int x[n], y[n], h[n];
	bool ok;

	rep(i, n) cin >> x[i] >> y[i] >> h[i];
	for(int i = 0; i <= 100; i++)
	{
		for(int j = 0; j <= 100; j++)
		{
			int needH = -1;
			ok = true;
			rep(k, n)
			{
				if (h[k] > 0)
				{
					int tmp = h[k] + abs(i - x[k]) + abs(j - y[k]);
					if (needH == -1)
					{
						H = tmp;
						needH = -2;
					}
					else 
					{
						needH = 0;
						if (H != tmp)
							ok = false;
					}
				}	
			}
			if (ok && !needH)
			{
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
			if (needH == -2)
			{
				rep(k, n)
				{
					if (h[k] > 0)
					{
						cout << x[k] << " " << y[k] << " " << h[k] << endl;
						return 0;
					}
				}
			}
		}
	}
	return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

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

    ll res = 0;
    rep(i,n){
        if(i == 0) continue;
        if(a[i-1] > a[i]){
            res += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 5152
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
 
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
 
ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47320
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
S.insert(4," ")
puts S.join("")

Measured memory_bytes: 1788
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N % 2 == 0:
    C = []
    for c in [2*i+1 for i in range(N//2)]:
        C += [c] * 2
    if A == C:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    C = [0]
    for c in [2*i for i in range(1, N//2 + 1)]:
        C += [c] * 2
    if A == C:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)



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

int main()
{
    int n, max = 1, ans = 0;
    int a[15];
    int x[15][15], y[15][15];

    cin >> n;
    for(int i = 0; i < n; ++i) {
        max *= 2;
        cin >> a[i];
        for(int j = 0; j < a[i]; ++j)
            cin >> x[i][j] >> y[i][j];
    }

    for(int i = 0; i < max; ++i) {
        bool _break = false;
        for(int j = 0; j < n; ++j) {
            if(i & (1 << j)) {
                for(int k = 0; k < a[j]; ++k) {
                    if(i & (1 << (x[j][k] - 1)) ? !y[j][k] : y[j][k])
                        _break = true;
                }
            }
            if(_break) break;
        }
        if(!_break && ans < __builtin_popcount(i))
            ans = __builtin_popcount(i);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;

int n;
string s;
deque <int> d[200];
int l[MAXN], r[MAXN];
char c[MAXN];
long long ans;

void update(int f[], int pos, int delta) {
  for (; pos < n; pos = (pos | (pos + 1))) {
    f[pos] += delta;
  }
}

long long sum(int f[], int pos) {
  long long res = 0;
  for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
    res += f[pos];
  }
  return res;
}

long long sum(int f[], int l, int r) {
  return sum(f, r) - sum(f, l - 1);
}

int main() { 

  getline(cin, s);
  n = sz(s);

  for (int i = 0; i < sz(s); i++) {
    d[s[i] - 'a'].push_back(i);
  }

  int from = 0, to = n - 1;
  while (from < to) {
    int best = -1, bestCost = (int) 1e9;
    int bestMn, bestMx;
    for (int i = 0; i < 26; i++) {
      if (sz(d[i]) < 2) {
        continue;
      }
      int mn = d[i].front(), mx = d[i].back();
      int newMn = mn + sum(l, mn + 1, n - 1) - sum(r, 0, mn - 1);
      int newMx = mx + sum(l, mx + 1, n - 1) - sum(r, 0, mx - 1);
      int curCost = newMn - from + to - newMx;
      if (best == -1 || curCost < bestCost) {
        best = i; bestCost = curCost;
        bestMn = mn, bestMx = mx;
      }
    }
    if (best == -1) {
      puts("-1");
      return 0;
    }
    ans += bestCost;
    update(l, bestMn, 1);
    update(r, bestMx, 1);
    c[from] = (char) ('a' + best);
    c[to] = (char) ('a' + best);
    d[best].pop_front(); d[best].pop_back();
    from++; to--;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  int count = 0;
  for (int i = 0; i < 3; i = i + 1) {
    if (s.at(i) == t.at(i)) {
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long long  h , w , i , j , x , y , number[400][400] ;
	cin >> h >> w ;
	for ( i = 1 ; i <= h ; i ++ ){
		for ( j = 1 ; j <= w ; j++ ){
			cin >> number[i][j] ;
			number[i][w+1] += number[i][j] ;
			number[h+1][j] += number[i][j] ;
			number[h+1][w+1] += number[i][j] ; 
	}
}
	for ( i = 1 ; i <= h ; i ++ ){
		for ( j = 1 ; j <= w ; j ++ ){
			cout << number[i][j] << " " ;
		}
		cout << number[i][w+1] ;
		cout << endl ;
	}
	for ( j = 1 ; j <= w ; j ++ ){
		cout << number[h+1][j] << " " ;
	}
	cout << number[h+1][w+1] << endl ;
}

Measured memory_bytes: 1480
#include <iostream>
#include<string.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n==1)
    {
        if(a==b)
        cout<<"1"<<endl;
        else
            cout<<"0"<<endl;
        return 0;
    }
    else if(n==2)
    {
        if(a<=b)
        cout<<a+b<<endl;
        else
            cout<<"0"<<endl;
        return 0;
    }
    if(a>b)
    {
        cout<<"0"<<endl;
        return 0;
    }
    n-=2;
    long long z1=b*n;
    long long z2=a*n;
    cout<<z1-z2+1<<endl;

}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
verdict = list()
while n:
    n -= 1
    verdict.append(input())

dictOBJ = dict()
dictOBJ = { 'AC' : 0, 'WA' : 0, 'TLE' : 0, 'RE' : 0}
for elm in verdict:
    dictOBJ[elm] += 1

print('AC x', dictOBJ['AC'])
print('WA x', dictOBJ['WA'])
print('TLE x', dictOBJ['TLE'])
print('RE x',dictOBJ['RE'])


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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

const int N = 10;
int n , a[N] , b[N];

double dis(int i , int j){
    double x = a[i] - a[j];
    double y = b[i] - b[j];
    return sqrt(x*x + y*y);
}

int main()
{
    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> a[i] >> b[i];
    double ans = 0.0;
    for(int i = 1; i <= n; ++i){
        for(int j = i + 1; j <= n; ++j){
            ans += dis(i , j) * 2 / n;
        }
    }

    cout << fixed << setprecision(10) << ans << "\n";

    return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	multiset<int> nums;
	nums.insert(a);
	nums.insert(b);
	nums.insert(c);
	
	if ( nums.count(5) == 2 && nums.count(7) == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    unordered_map<int, vector<int>> dict;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        dict[a].push_back(b);
        dict[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) {
        cout << dict[i].size() << endl;
    }

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = (1 << 30) - 1;

int n;
int dist[105][105];

int prim()
{
    int d[105];
    bool flag[105] = {};
    int cnt = 0, sum = 0;
    fill_n(d, 105, INF);
    d[0] = 0;
    
    while ( true ) {
        int u = -1;
        for ( int i = 0; i < n; i++ ) {
            if ( !flag[i] && (u == -1 || d[u] > d[i] ) ) u = i;
        }
        
        flag[u] = true;
        sum += d[u];
        cnt++;
        if ( cnt == n ) break;

        for ( int i = 0; i < n; i++ ) {
            if ( !flag[i] && dist[u][i] != -1 && d[i] > dist[u][i] ) {
                d[i] = dist[u][i];
            }
        }
    }

    return ( sum );
}

int main()
{
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) {
            cin >> dist[i][j];
        }
    }
    cout << prim() << endl;
    return ( 0 );
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    ll ave = 0;
    rep1(i, n){
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());
    ll mid;
    if (n%2==0){
        mid = (a[n/2] + a[n/2-1]) / 2;
        mid += (a[n/2]-mid < mid-a[n/2-1]);
    }
    else mid = a[n/2];
    ll ans= 0;
    rep1(j, n) ans += abs(a[j]-mid);
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 4756
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<queue>
#define fo(n)for(int i = 0; i<n ; i++)
#define fo1(n)for(int i = 1; i<=n ; i++)
using namespace std;
vector<int>G[2005];
int vis[2005];
int len[2005];
queue<pair<int, int> >q;
void bfs(int now, int deep)
{
	memset(vis, 0, 2005*sizeof(int));
	
	q.push(make_pair(now, deep));
	int no, dep;
	vis[now] = 1;
	while (!q.empty())
	{
		no = q.front().first;
		dep = q.front().second;
		vis[no] = 1;
		len[dep]++;
		q.pop();
		fo(G[no].size())
		{
			if (!vis[G[no][i]])
			{
				q.push(make_pair(G[no][i], dep + 1));
				vis[G[no][i]] = 1;
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x, y;
	cin >> n >> x >> y;
	for (int i = 1; i <= n - 1; i++)
	{
		G[i].push_back(i + 1);
		G[i + 1].push_back(i);
	}
	G[x].push_back(y);
	G[y].push_back(x);
	for (int i = 1; i <= n; i++)
	{
		bfs(i, 0);
	}
	for (int i = 1; i < n; i++)
	{
		cout << len[i] / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
 cin>>a>>b;
 if(b<=a*4&&b>=2*a){
     if(b%2==0||b%4==0||b%6==2||b%6==4)cout<<"Yes";
     else{
         cout<<"No";
     }}
     else{
         cout<<"No";
     }
 
  return 0;
}

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

#define FOR(a, b, c) for (int a = (b), _for = (c); a < _for; ++a)
#define REP(a, n) FOR(a, 0, n)
#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

int main(){
	int a,b;
	scanf ("%d%d",&a,&b);
	printf ("%d\n",6-a-b);
	
	
	
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > D;
  int DD;
  std::vector<int > time;
  time.push_back(0);
  std::map<int, int> count;
  for (int i=0; i<N; i++){
    scanf("%d", &DD);
    count[DD]++;
  }
  for (auto &entry: count){
    if (entry.second>2){
      printf("0\n");
      return 0;
    } else if (entry.second==2){
      time.push_back(entry.first);
      time.push_back(24-entry.first);
    } else if (entry.first%12==0){
      time.push_back(entry.first);
    } else {
      D.push_back(entry.first);
      //printf("pushing D to %d\n", entry.first);
    }
  }
  if (D.size()+time.size()>24){
    printf("0\n");
  } else {
    int s;
    if (D.size()>0){
      s=0;
      for (int i=0; i<(1<<D.size())-1; i++){
	//printf("i=%d\n", i);
	std::vector<int > vec(time.size());
	std::copy(time.begin(), time.end(), vec.begin());
	for (int j=0; j<D.size(); j++){
	  if ((i&(1<<j))!=0){
	    vec.push_back(D[j]);
	  } else {
	    vec.push_back(24-D[j]);
	  }
	  //printf("time[%d]=%d\n", vec.size()-1, vec[vec.size()-1]);
	}
	std::sort(vec.begin(), vec.end());
	int temp=1000000;
	for (int j=0; j<vec.size()-1; j++){
	  temp=std::min(temp, vec[j+1]-vec[j]);
	}
	temp=std::min(temp, 24-vec[vec.size()-1]);
	//printf("i=%d, temp=%d\n", i,temp);
	s=std::max(s, temp);
      }
    } else {
      std::sort(time.begin(), time.end());
      s=100000;
      for (int i=0; i<time.size()-1; i++){
	s=std::min(s, time[i+1]-time[i]);
      }
      s=std::min(s, 24-time[time.size()-1]);
    }
    std::cout << s << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
nt = list(map(int, input().split()))
ci = []
costs = []

for i in range(nt[0]):
    ci.append(list(map(int, input().split())))

for i in range(nt[0]):
    if ci[i][1] <= nt[1]:
        costs.append(ci[i][0])

if len(costs) == 0:
    print("TLE")
else:
    print(min(costs))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  string s,t;
  cin>>s>>t;
  ll l=s.length(),m=t.length(),r=0,c=-1,j;
  vector<vector<ll>> v(26);
  for(j=0;j<l;j++) v[s[j]-'a'].push_back(j);
  for(j=0;j<m;j++){
    if(v[t[j]-'a'].size()==0){
      cout<<-1<<endl;
      return 0;
    }
    auto it=upper_bound(v[t[j]-'a'].begin(),v[t[j]-'a'].end(),c);
    if(it==v[t[j]-'a'].end()){
      r++;
      c=*v[t[j]-'a'].begin();
    }
    else c=*it;
  }
  cout<<r*l+c+1<<endl;
}

Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int maxn = 2e5+10;
map<int, bool> vis;
ll n, ans;
ll solve1(ll x)
{
    ll res = 1; vis[x] = true;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i!=0) continue;
        ll j = x/i, xx = x;
        if(!vis[i])
        {
            while(xx%i==0) xx/=i;
            if(xx%i==1) res++;
            vis[i] = true;
        }
        if(!vis[j])
        {
            xx = x;
            while(xx%j==0) xx/=j;
            if(xx%j==1) res++;
            vis[j] = true;
        }
    }
    return res;
}
ll solve2(ll x)
{
    ll res = 1;
    vis.clear(); vis[x] = true;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i!=0) continue;
        ll j = x/i;
        if(!vis[i]) vis[i] = true, res++;
        if(!vis[j]) vis[j] = true, res++;
    }
    return res;
}
int main()
{
    //freopen("/Users/zhangkanqi/Desktop/11.txt","r",stdin);
    scanf("%lld", &n);
    if(n==2) printf("1\n");
    else printf("%lld\n", solve1(n)+solve2(n-1));
    return 0;
}

Measured memory_bytes: 512