akhauriyash/Code-Regression huggingface dataset:
/*
Date: 2017/01/22 21:00:01 Sunday
*/
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C,x,y;
vector<int>a[N];
int dfs(int x,int f){
	int sum[33];
	rep(i,0,30)sum[i]=0;
	int msk=0;
	for(auto i:a[x])if(i!=f){
		int p=dfs(i,x);
		msk|=p;
		rep(i,0,30)if(p&(1<<i))sum[i]++;
	}
	int q=-1;rep(i,0,30)if(sum[i]>1)q=i;
	rep(i,0,30)if((!(msk&(1<<i)))&&i>q)return msk|(1<<i);
	else msk&=~(1<<i);
}
int main(){
#ifdef LOCAL
	freopen("D.in","r",stdin);//freopen("D.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,2,n)scanf("%d%d",&x,&y),a[x].pb(y),a[y].pb(x);
	int p=dfs(1,0);
	dep(i,30,0)if((1<<i)&p){printf("%d\n",i);return 0;}
	return 0;
}

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

#define PI 3.1415926535

double circumference(double r)
{
    double cir = 2*PI*r;
    return cir;
}
int main()
{
  double r;
  cin >> r;
  cout << circumference(r);
  return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#include<cstdlib>
#include<sstream>
#include<algorithm>
#include<cassert>
using namespace std;

string Replace(string s,char c){
  string res;
  res.clear();
  for(int i=0;i<s.length();i++){
    if(s[i] == 'X')res+=c;
    else res+=s[i];
  }
  return res;
}

string its(int num){
  stringstream ss;
  ss << num;
  return ss.str();
}

string calc(string a,string b){
  string s,val;
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  int A,B,C,D;//D<-繰り上がり分
  D=0;
  for(int i=0;i<max(a.size(),b.size());i++){
    if(i>=a.size()){
      B = b[i]-'0';
      C = B+D;
      val = its(C);
      assert(C<=20);
      if(C>=10)D=1;
      else D=0;
      s+=val[val.size()-1];
    }
    else if(i>=b.size()){
      A = a[i]-'0';
      C = A+D;
      val = its(C);
      assert(C<=20);
      if(C>=10)D=1;
      else D=0;
      s+=val[val.size()-1];
    }
    else{
      A = a[i]-'0';
      B = b[i]-'0';
      C = A+B+D;
      val = its(C);
      assert(C<=20);
      if(C>=10)D=1;
      else D=0;
      s+=val[val.size()-1];
    }
  }
  if(D == 1){
    s+='1';
  }
  reverse(s.begin(),s.end());
  return s;
}

bool isEqual(string a,string b){
  if(a.size() != b.size())return false;
  bool same = true;
  for(int i=0;i<a.size();i++){
    if(a[i] != b[i]){
      same = false;
      break;
    }
  }
  return same;
}

int main(){
  string s;
  int st,A,B,C,index;
  string Smen[3],As,Bs,Cs;
  string lans,rans;

  while(cin >> s){
    st = index = 0;

    for(int i=0;i<=s.length();i++){
      if(s[i] == '+' || s[i] == '=' || i == s.length()){
	Smen[index++]=s.substr(st,i-st);
	st = i+1;
      }
    }
    char c='0';
    bool found = false;
    for(int i=0;i<=9;i++){
      c=(char)('0'+i);
      
      if(i == 0 && ((Smen[0][0] == 'X' && Smen[0].size() > 1) || (Smen[1][0] == 'X' && Smen[1].size() > 1)|| (Smen[2][0] == 'X' && Smen[2].size() > 1)))continue;
      As = Replace(Smen[0],c);
      Bs = Replace(Smen[1],c);
      Cs = Replace(Smen[2],c);
      lans = calc(As,Bs);
      rans = Cs;
      if(isEqual(lans,rans)){
	cout << i << endl;
	found = true;
	break;
      }
    }  
    if(!found)cout << "NA" << endl;

  }
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    vector<pair<string,pii> > a(n);
    rep(i,n){
        cin >> a[i].first >> a[i].second.first;
        a[i].second.first *= -1;
        a[i].second.second = i;
    }
    sort(all(a));
    rep(i,n)cout << a[i].second.second+1 << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  vector<vector<P>> edge(N);
  vi col(N,-1);

  REP(i,N-1){
    int u,v,w;
    cin >> u >> v >> w;
    u--; v--;
    edge[u].emplace_back(v,w);
    edge[v].emplace_back(u,w);
  }

  queue<int> q;
  col[0]=0;
  q.push(0);

  while(!q.empty()){
    int x = q.front();
    q.pop();
    
    for(auto e: edge[x]){
      int y = e.first;
      int w = e.second;
      if(col[y]!=-1)continue;

      if(w%2==0){
        col[y] = col[x];
      }else{
        col[y] = col[x] ^ 1;
      }
      q.push(y);
    }
  }

  REP(i,N){
    cout << col[i] << endl;
  }
}



Measured memory_bytes: 9548
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0

for i in range (N):
    ans+=B[A[i]-1]

for j in range(1,N):
    if A[j]==A[j-1]+1:
        ans+=C[A[j]-2]

print(ans)

Measured memory_bytes: 9092
def isStorage(max_shelf):
	i,cur_shelf,num = 0,0,1
	while i < n:
		if num > m:
			return False
		if cur_shelf + book[i] > max_shelf:
			num += 1
			cur_shelf = 0
		else:
			cur_shelf += book[i]
			i += 1
	else:
		return True
			
while 1:
	m,n = map(int,raw_input().split())
	if m==0: break
	book = [int(raw_input()) for i in range(n)]
	max_shelf = len = sum(book)/2
	while len:
		len /= 2
		max_shelf -= len if isStorage(max_shelf) else -len
	max_shelf += 6
	while isStorage(max_shelf-1):
		max_shelf -= 1
	print max_shelf

Measured memory_bytes: 4236
#include<stdio.h>
int i,j,n,v,u,k,time,data[101][101],d[101],f[101];
void visit(int u){
  int v;
  d[u]=time++;

  for(v = 1; v <= n; v++){
    if(data[u][v]&d[v]==0)
      visit(v);
  }
  f[u]=time++;
}

int main(){
  time=1;
  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      data[i][j]=0;
      d[j]=0;
      f[j]=0;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      data[u][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    if(d[i]==0)visit(i);
  }
  for(i = 1;i <= n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int i,n;
ll a[3*nmax],l[3*nmax],r[3*nmax],ans=-(1LL<<60);
multiset<ll>s;
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=3*n;i++)cin>>a[i];
	for(i=1;i<=3*n;i++)
	{
		s.in(a[i]);
		l[i]=l[i-1]+a[i];
		if(s.size()>n)
		{
			l[i]-=(*s.begin());
			s.erase(s.begin());
		}
	}
	s.clear();
	for(i=3*n;i>=1;i--)
	{
		s.in(-a[i]);
		r[i]=r[i+1]+a[i];
		if(s.size()>n)
		{
			r[i]+=(*s.begin());
			s.er(s.begin());
		}
	}
	for(i=n;i<=2*n;i++)ans=max(ans,l[i]-r[i+1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12032
#include <stdio.h>
int main(){
	short i = 0;
	int n,m,x;
	scanf("%d%d%d",&n,&m,&x);
	int nums[m];
	for(i = 0;i < m; ++i) {
		scanf("%d",&nums[i]);
	}
	i = 0;
	do{
		if (nums[i] > x){
			if (i < m - i){
				printf("%d",i);
			}
			else{
				printf("%d",m - i);
			}

		}
		i += 1;
	}while(nums[i - 1] < x && i  < m);
	if(i  > m) printf("0");
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define black 1
#define white 0
typedef long long ll;

ll mod = 1000000007;
vector <vector<int>> adjlist(100001,vector<int>());
ll dp[100005][2];

ll go(int node,int parent,int paint)
{
    if(dp[node][paint] != -1)
        return dp[node][paint];
    
    ll w1  = 1;
    ll ans = 0;
    
    // white toh bacche ko paint kar hi sakte hain
    for(auto child : adjlist[node])
    {
        if(child != parent)
        {
            w1 = ((w1%mod)*(go(child,node,white)%mod))%mod;
        }
    }
    
    ans = (ans%mod + w1%mod)%mod;
    
    // agar parent white hai , tabhi bacche ko black karenge paint
    if(paint == white)
    {
        ll w2 = 1;
        for(auto child : adjlist[node])
        {
            if(child != parent)
            {
                w2 = ((w2%mod)*(go(child,node,black)%mod))%mod;
            }
        }
        ans = (ans%mod + w2%mod)%mod;
    }
    
    dp[node][paint] = ans;
    return ans;
}

int main()
{
    int n;
    cin >> n;
    
    memset(dp,-1,sizeof(dp));
    
    int a,b;
    for(int i=1;i<=n-1;i++)
    {
        cin >> a >> b;
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }
    
    cout << go(1,-1,white) << endl;
    
    return 0;
}

Measured memory_bytes: 15616
L,N = map(int,input().split())
X = [int(input()) for i in range(N)]

if N == 1:
    print(max(X[0],L-X[0]))
    exit()

cum_l = [0]
for x in X:
    cum_l.append(cum_l[-1] + x)

cum_r = [0]
for x in reversed(X):
    cum_r.append(cum_r[-1] + L-x)

ans = 0
for st_l in range(1,N+1):
    m = N - st_l
    r = m - m//2
    l = st_l + m//2
    tmp = (cum_l[l] - cum_l[st_l-1] + cum_r[r]) * 2
    if m%2:
        tmp -= (L - X[-r])
    else:
        tmp -= X[l-1]
    ans = max(ans, tmp)

for st_r in range(1,N+1):
    m = N - st_r
    l = m - m//2
    r = st_r + m//2
    tmp = (cum_r[r] - cum_r[st_r-1] + cum_l[l]) * 2
    if m%2:
        tmp -= X[l-1]
    else:
        tmp -= (L - X[-r])
    ans = max(ans, tmp)

print(ans)

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

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

	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}
}


Measured memory_bytes: 3108
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
}

signed main() {
	static bool is_prime[1000010] = {};
	eratos(1000010, is_prime);
	for (int n; cin >> n&&n;) {
		int ans = 0;
		rep(i, 0, n / 2 + 1) {
			if (is_prime[i] && is_prime[n - i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4056
using System;
using System.Collections.Generic;
using System.Linq;
namespace program{
    public class ABC167{
        public static void Main(string[] args){
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            if(t.IndexOf(s) == 0 && t.Length - s.Length == 1){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 26160
package main

import (
	"fmt"
	"math"
)

type point struct {
	x, y float64
}

type line struct {
	p1, p2 point
}

func kochCurve(d int, p1, p2 point) {
	if d == 0 {
		return
	}

	th := float64(math.Pi * 60 / 180.0)

	// TODO p1, p2 から 頂点 s, t, u を計算
	var s, t, u point
	s.x = (2*p1.x + p2.x) / 3
	s.y = (2*p1.y + p2.y) / 3
	t.x = (p1.x + 2*p2.x) / 3
	t.y = (p1.y + 2*p2.y) / 3
	u.x = (t.x - s.x) * math.Cos(th) - (t.y - s.y) * math.Sin(th) + s.x
	u.y = (t.x - s.x) * math.Sin(th) + (t.y - s.y) * math.Cos(th) + s.y

	// first line of koch curve
	kochCurve(d-1, p1, s)

	// second
	fmt.Println(s.x, s.y)
	kochCurve(d-1, s, u)

	// third
	fmt.Println(u.x, u.y)
	kochCurve(d-1, u, t)

	// forth
	fmt.Println(t.x, t.y)
	kochCurve(d-1, t, p2)
}

func main() {
	var n int
	fmt.Scanf("%d", &n)

	p1 := point{0, 0}
	p2 := point{100, 0}

	fmt.Println(p1.x, p1.y)
	kochCurve(n, p1, p2)
	fmt.Println(p2.x, p2.y)
}


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

long long int dp[1001][1001];      /// dp[i][j] = count of way to get from (0, 0) to (n, m)
char grid[1001][1001];
const int mod = 1e9+7;

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

    int n, m;
    cin>>n>> m;

    for(int i = 0; i<n; i++)
        cin>>grid[i];

    for(int i = 0; i<n; i++){
        for(int j = 0; j<m; j++){
            if(grid[i][j] == '#'){
                dp[i][j] = 0;
                continue;
            }


            if(i == 0 && j == 0){
                dp[i][j] = 1;
                continue;
            }

            if(i > 0)
                dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
            if(j > 0)
                dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;

        }
    }

    cout<<dp[n-1][m-1]<<endl;

    return 0;
}



Measured memory_bytes: 12388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int N , K , S;
    cin >> N >> K >> S;
    for (int i = 1; i <= K; i++){
        cout << S << " ";
    }
    int T = N - K;
    for (int i = 1; i <= T; i++){
        if (S == 1000000000){
            cout << S - 1 << " ";
        }
        else{
            cout << S + 1 << " ";
        }
    }
}

Measured memory_bytes: 3636
use std::cmp::min;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let mut p = vec![];
    let n: i128 = sc.read();

    let mut t = n * 2;
    for x in 2.. {
        if x * x > n {
            break;
        }
        let mut cur = 1;
        while t % x == 0 {
            cur *= x;
            t /= x;
        }
        if cur > 1 {
            p.push(cur);
        }
    }
    if t > 1 {
        p.push(t);
    }

    let p_len = p.len();
    let mut ans = if (n * (n + 1) / 2) % n == 0 { n } else { 2 * n };
    for mask in 0..(1 << p_len) {
        let mut a = 1;
        let mut b = 1;
        for i in 0..p_len {
            if mask & (1 << i) != 0 {
                a *= p[i];
            } else {
                b *= p[i];
            }
        }

        if a == 1 || b == 1 {
            continue;
        }

        let mut x = 0;
        let mut y = 0;
        let g = ext_gcd(a, b, &mut x, &mut y);
        assert_eq!(g, 1);
        assert_eq!(a * x + b * y, 1);
        let k = min((a * x).abs(), (b * y).abs());

        let z = k * (k + 1) / 2;
        assert_eq!(z % n, 0);
        ans = min(ans, k);
    }

    println!("{}", ans);
}

fn ext_gcd(a: i128, b: i128, x: &mut i128, y: &mut i128) -> i128 {
    let mut d = a;
    if b != 0 {
        d = ext_gcd(b, a % b, y, x);
        *y -= (a / b) * *x;
    } else {
        *x = 1;
        *y = 0;
    }
    d
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main() {
	int n; cin >> n;
	vector<long double>v(n); for (auto&& x : v)cin >> x;
	sort(v.begin(), v.end());

	long double ans = v[0];
	for (int i = 1; i < n; i++) {
		ans = (ans + v[i]) / 2;
	}
	cout << ans << endl;

	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, minv=LLONG_MAX, numw=0, nume=0;
  string s;
  cin >> n >> s;
  vecll x(n);
  forll(i, 0, n){
	if (s[i] == 'E')
	  nume++;
  }
  forll(i, 0, n){
	if (s[i] == 'E'){
	  nume--;
	  x[i] = nume + numw;
	}
	else{
	  x[i] = nume + numw;
	  numw++;
	}
  }
  forll(i, 0, n){
	minv = min(minv, x[i]);
  }
  cout << minv << endl;
}


Measured memory_bytes: 3076
s = input()
a = 0
for i in range(0,len(s),2):
    if s[i] == 'L' :
        a += 1
for i in range(1,len(s),2):
    if s[i] == 'R':
        a += 1
if a == 0 :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

string A,B;

ll dp[1007][1007];

int LCS(string A,string B){
    REP(i,1,A.size()+1){
        REP(j,1,B.size()+1){
            if(A[i-1]==B[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    return dp[A.size()][B.size()];
}

int main(){
    ll N;cin>>N;
    rep(i,N){
        cin>>A>>B;
        cout << LCS(A,B) << endl;
    }
}


Measured memory_bytes: 11012
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	int K = Integer.parseInt(scan.next());
	int[] l = new int[N];
	for (int i = 0; i < N; i++) {
	    l[i] = Integer.parseInt(scan.next());
	}

	Arrays.sort(l);
	int length = 0;
	for (int i = N-1; i >= N-K; i--) {
	    length += l[i];
	}

	System.out.println(length);
	scan.close();
    }
}


Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int main()
{
	double v1,v2,l[10];
	int i;
	char a;
	
	for(;cin >> l[0];)
	{
		double n=l[0];
		for(i=1;i<10;i++)
		{
			cin >> a >> l[i];
			n+=l[i];
		}
		cin >> a >> v1 >> a >> v2;
		double t;
		t=n/(v1+v2);
		n=v1*t;
		for(i=0;i<10;i++)
		{
			n-=l[i];
			if(0.0==n)
			{
				i++;
				break;
			}
			if(0.0>n)
			{
				i++;
				break;
			}
		}
		cout << i << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int count = 0;
	string t = "";
	for(int i = s.size() - 1; i >= 0; i--) {
		t = s[i] + t;
		count++;
		if(count == 5) {
			if(t == "erase" or t == "dream") {
				count = 0;
				t = "";
			}
		} else if(count == 6) {
			if(t == "eraser") {
				count = 0;
				t = "";
			} 
		} else if(count == 7) {
			if(t == "dreamer") {
				count = 0;
				t = "";
			} else {
				cout << "NO" << endl;
				return 0;
			}

		}
	}
	cout << "YES" << endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,c; cin >> a >> b >> c;
    int k; cin >> k;
    int index = 0;
    while(a>=b){
        index++;
        b*=2;
    }
    while(b>=c){
        index++;
        c*= 2;
    }
    if(index<=k){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3664
import java.util.*;
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count = 0;
    for (int i=0; i<N; i++) {
      int num = sc.nextInt();
      count += ((i+1)%2 != 0 && num%2 != 0)?1 : 0;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 35748
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int a,b; cin>>a>>b;
    if(a>9 || b>9){
        cout<<-1;
        return 0;
    }
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 256
from math import *
n = int(input())
engine = [list(map(int, input().split())) for i in range(n)]

args = []
for i in range(n):
    x, y = engine[i]
    if x == 0:
        if y < 0:
            args.append((-pi/2, x, y))
        elif y > 0:
            args.append((pi/2, x, y))

    elif y == 0:
        if x > 0:
            args.append((0, x, y))
        elif x < 0:
            args.append((pi, x, y))

    else:
        args.append((atan2(y, x), x, y))

args.sort()
l = len(args)
args = args[:] + args[:]
ans = 0
for i in range(1, l+1):
    for j in range(l):
        x, y = 0, 0
        for k in range(j, j+i):
            x += args[k][1]
            y += args[k][2]
        ans = max(ans, (x**2+y**2)**(1/2))

print(ans)


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

typedef long long ll;
int n, cnt;
int bits(int x) {
    int res = 0;
    while (x) {
        ++res;
        x /= 10;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (bits(i) & 1)
            ++cnt;
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int maxn = 320;
int g[maxn][maxn];
bool good[maxn];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    int f = -1, l = -1;
    int cnt = 1;
    for(int i = 0 ; i < n ; ++i)
        for(int j = 0 ; j < m ; ++j){
            char c;
            cin >> c;
            if(c == '#'){
                g[i][j] = cnt++;
                good[i] = true;
            }
                
        }
    assert(cnt == k + 1);
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < m ; ++j)
            if(g[i][j] != 0){
                int k = j - 1;
                while(k >= 0 && g[i][k] == 0){
                    g[i][k] = g[i][j];
                    --k;
                }
                k = j + 1;
                while(k < m && g[i][k] == 0){
                    g[i][k] = g[i][j];
                    ++k;
                }
            }
    }
    for(int l = 0 ; l < n ; ++l)
        for(int j = 0 ; j < m ; ++j){
            if(!good[l]) continue;
            int i = l - 1;
            while(i >= 0 && !good[i]){
                g[i][j] = g[l][j];
                if(j == m - 1) good[i] = true;
                --i;
            }
            i = l + 1;
            while(i < n && !good[i]){
                g[i][j] = g[l][j];
                if(j == m - 1) good[i] = true;
                ++i;
            }   
        }

    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < m ; ++j)
            cout << g[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}


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

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

int main() {
  int x;
  cin >> x;
  if (x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}



Measured memory_bytes: 256
k, n = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

a1 = as.first
an = as.last
dd = Array.new(n, 0)

(n - 1).times do |i|
  dd[i] = as[i + 1] - as[i]
end
dd[-1] = k - an + a1

puts dd.inject(:+) - dd.max


Measured memory_bytes: 18948
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<int>ans(n);
    rep(i,n/2){
        ans[i] = a[n-1-i*2];
        ans[n-1-i] = a[n-2-i*2];
    }
    if(n%2){
        ans[n/2] = a[0];
    }
    rep(i,n-1){
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;
}


Measured memory_bytes: 3712
#include <stdio.h>
int main () {
	
	long int a,b, count = 0;
	long int time = 0;
	float t;
	scanf("%ld %ld %f", &a, &b, &t);
	float t2 = t + 0.5;
 	for (int i = a; i < t2; i = i + a){
		 count = count + b;
		 time = i;
	 }
	
	 //long int x = (count*t2)/time;
	 printf("%ld", count);
	 //printf(" ------ %ld", x);
	
	
	
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll N, tmp;
  vector<ll> orig, v;
  cin >> N;
  rep(i,N){
    cin >> tmp;
    orig.push_back(tmp);
  }
  v = orig;
  sort(v.begin(), v.end());
  ll c[200010]={};
  ll sum=0;
  rep(i, N){
    c[v[i]]++;
  }
      
  /*rep(i, 200010){
    c[i] = count(v.begin(), v.end(), i);
  }*/
  rep(i, 200010){
    sum += c[i]*(c[i]-1)/2;
  }
  rep(i, N){
    if(c[orig[i]]!=0){
	  cout << sum - c[orig[i]] + 1 << endl;
    }else{
      cout << sum << endl;
    }
  }
  //cout << c[0] << c[1] << c[2] << c[3] << c[4] << endl;
  //cout << sum << endl;
  
}

Measured memory_bytes: 7408
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll mod = 1e9 + 7, comb[100001];
ll power(ll x, ll y) {
	ll ans = 1;
	while(y) {
		if(y & 1) {
			ans = (ans * x)%mod;
		}
		y/=2;
		x = (x * x)%mod;
	}
	return ans;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, i, sum = 0;
    cin>>n>>k;
    ll fact[3*n];
    fact[0] = 1;
    fact[1] = 1;
    for(i=2; i<3*n; i++) {
    	fact[i] = (fact[i-1]*i)%mod;
    }
    for(i=k-2; i<=n; i++) {
    	ll n1 = fact[i];
    	ll d = (fact[k-1] * fact[i - k + 1])%mod;
    	d = power(d, mod - 2);
    	comb[i] = (n1 * d)%mod;
    }
    vector<ll> v(n);
    for(i=0; i<n; i++) {
    	cin>>v[i];
    }
    if(k == 1) {
    	cout<<0<<"\n";
    	return 0;
    }
    sort(all(v));
    for(i=0; i<n; i++) {
    	if(i + k - 1 < n)
    		sum = ((sum - v[i]*comb[n - i - 1])%mod + mod)%mod;
    	if(i - k + 1 >= 0)
    		sum = (sum + v[i]*comb[i])%mod;
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3840
import sys


def count(i, r=-1):
    for e in es[i]:
        if e != r:
            counter[e] += counter[i] + rc[e]
            count(e, i)


if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    es = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        es[a-1].append(b-1)
        es[b-1].append(a-1)
    counter = [0]*N
    rc = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        rc[p-1] += x
    counter[0] = rc[0]
    count(0)
    print(*counter)


Measured memory_bytes: 274428
#include <bits/stdc++.h>
#define _xx ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long LL;

int a[200100];
int b[200100];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    int m=n/2;
    for(int i=1;i<=n;i++){
        if(a[i]<=b[m]) cout<<b[m+1]<<endl;
        else cout<<b[m]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  ll a, b;
  cin >> a >> b;
  if ((a - b) % 2) cout << "IMPOSSIBLE" << endl;
  else {
    cout << (a + b) / 2 << 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++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  string S; cin >> S;
  long long ans = 0;
  REP(i, 1 << (S.size() - 1)) {
    string plus = "";
    REP(j, S.size() - 1) {
      plus += S[j];
      if ((i >> j) & 1) {
        plus += "+";
      }
    }
    plus += S[S.size() - 1];
    plus += "+";

    long long temp = 0;
    long long num = 0;
    REP(i, plus.size()) {
      if (plus[i] == '+') {
        temp += num;
        num = 0;
      } 
      else {
        num = num * 10 + (plus[i] - '0');
        // cout << plus[i] - '0' << endl;
      }
      
    }
    // cout << temp << endl;
    ans += temp;
    // cout << plus << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

MOD = 10 ** 9 + 7

n, *a = map(int, sys.stdin.read().split())

def main():
    c = Counter(a)
    if n & 1:
        if c.get(0, 0) != 1:
            return 0
    for i in range(1 + (n & 1), n, 2):
        if c.get(i, 0) != 2:
            return 0

    return pow(2, n // 2, MOD)
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14196
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>



using namespace std;

long long dp[301][90002];
long long dp2[301][90002];
int a[301];
int n;
long long MOD = 998244353;

int main(){
	cin>>n;
	int total =0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		total += a[i];
	}
	sort(a,a+n);

	dp[0][0] = 1LL;
	for(int i=1;i<=n;i++){
		for(int j=0;j<90002;j++){
			dp[i][j] = (dp[i][j]+dp[i-1][j]*2) % MOD;
			if(j >= a[i-1]){
				dp[i][j] = (dp[i][j] + dp[i-1][j-a[i-1]]) % MOD;
			}
		}
	}
	dp2[0][0] = 1LL;
	for(int i=1;i<=n;i++){
		for(int j=0;j<90002;j++){
			dp2[i][j] = (dp2[i][j]+dp2[i-1][j]) % MOD;
			if(j >= a[i-1]){
				dp2[i][j] = (dp2[i][j] + dp2[i-1][j-a[i-1]]) % MOD;
			}
		}
	}

	int ans = 0;
	long long tmp3 =1;
	for(int i=0;i<n;i++){
		tmp3 = (tmp3*3LL) % MOD;
	}

	for(int i=0;i<=90002;i++){
		if(i  >= (total -i)) tmp3 = (tmp3 - dp[n][i]*3LL + MOD) % MOD;
		//cout<<tmp3<<endl;
		if(i == (total -i)) tmp3 = (tmp3 + dp2[n][i]*3LL + MOD) % MOD;
	}

	cout<<tmp3<<endl;

	return 0;

}

Measured memory_bytes: 422784
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
  dp[i] = min(dp[i - k] + abs(h[i]-h[i-k]) for k in [1, 2])

print(dp[-1])

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

int main()
{
    long long int a[3];
    for (int i = 0;i<3;i++)
        cin >> a[i];
    sort(a, a + 3);
    if(a[2]%2==0)
        cout << 0;
    else
        cout << a[0] * a[1];
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  ll L, R; cin >> L >> R;
  if (R - L + 1 >= 2019) {
    cout << 0 << endl;
  } else {
    ll min = inf;
    for (ll i = L; i <= R; i++) for (ll j = i + 1; j <= R; j++) {
      min = std::min(min, (i % 2019) * (j % 2019) % 2019);
    }
    cout << min << endl;
  }
}


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

using ll = long long;

const int MAXN = 2e5;
const int MAXM = 2e5;
int N, M;
ll A[MAXN];
pair<ll, int> C[MAXM];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		int b; ll c; cin >> b >> c;
		C[i] = make_pair(c, b);
	}
	sort(A, A + N);
	sort(C, C + M, greater<pair<ll, int>>());

	vector<ll> cnds;
	for (int i = 0; i < M; i++) {
		for (int j = 0; int(cnds.size()) < N && j < C[i].second; j++) {
			cnds.push_back(C[i].first);
		}
	}

	ll ans = 0;
	for (int i = 0, j = 0; i < N; i++) {
		if (j < int(cnds.size()) && cnds[j] > A[i]) {
			A[i] = cnds[j];
			j++;
		}
		ans += A[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4984
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let mut vec: Vec<u32> = line.split_whitespace().map(|s| s.parse::<u32>().unwrap()).collect();
    vec.sort();
    println!("{} {} {}", vec[0], vec[1], vec[2]);
}


Measured memory_bytes: 5024
#include<stdio.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b){
		printf("%d\n",c);
	}else if(a==c){
		printf("%d\n",b);
	}else{
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 128
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	nk := strings.Split(sc.Text(), " ")
	// n, _ := strconv.Atoi(nk[0])
	k, _ := strconv.Atoi(nk[1])

	sc.Scan()
	l := strings.Split(sc.Text(), " ")
	var ls []int

	for _, lss := range l {
		li, _ := strconv.Atoi(lss)
		ls = append(ls, li)
	}

	sort.Sort(sort.Reverse(sort.IntSlice(ls)))

	snake := 0

	for i := 0; i < k; i++ {
		snake += ls[i]
	}

	fmt.Println(snake)
}


Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MSIZE = 3003;

long long dp[MSIZE][MSIZE];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int * arr = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    for (int len = 1; len <= n; len++) {
        for (int l = 0; l + len <= n; l++) {
            int r = l + len - 1;
            if (l == r) {
                dp[l][r] = arr[l];
            } else {
                if (len & 1) {
                    dp[l][r] = max(
                                arr[l] + dp[l + 1][r],
                                arr[r] + dp[l][r - 1]
                            );
                } else {
                    dp[l][r] = min(
                                dp[l + 1][r] - arr[l],
                                dp[l][r - 1] - arr[r]
                            );
                }
            }
        }
    }

    cout << ((n & 1) ? dp[0][n - 1] : -dp[0][n - 1]) << endl;

}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-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_N=80;
const int MAX_C=25000000;

int N;
int A[MAX_N+1];
int dp[MAX_N+1];
int ans;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i];
    dp[0]=1000;
    for(int i=0;i<N;++i){
        chmax(dp[i+1],dp[i]);
        for(int j=0;j<=i;++j){
            int pl=(dp[j]/A[j])*A[i];
            int mn=(dp[j]/A[j])*A[j];
            chmax(dp[i+1],dp[j]-mn+pl);
        }
    }
    for(int i=0;i<=N;++i)chmax(ans,dp[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>

using namespace std;

int main(){
	int a,b,c,d;
	int j = 0;
	cin >> a ;
	cin >> b ;
	cin >> c ;
	cin >> d ;
	if(abs(a-b) <= d && abs(b-c) <= d) j = 1;
	if(abs(a-c) <= d) j = 1;
	if(j == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

       return 0;
}

Measured memory_bytes: 256
S = input()

N = len(S)
RL_positions = []
for i in range(N - 1):
    if S[i] == 'R' and S[i + 1] == 'L':
        RL_positions.append(i)

values = [0] * N

left, turn = 0, 1
while left < N:
    while S[turn] == 'R':
        turn += 1
    turn -= 1
    right = turn + 1
    while right < N and S[right] == 'L':
        right += 1
    right -= 1
    for i in range(left, right + 1):
        if i % 2 == turn % 2:
            values[turn] += 1
        else:
            values[turn + 1] += 1
    left, turn = right + 1, right + 2
print(' '.join(map(str, values)))


Measured memory_bytes: 52848
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
from random import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N, x = reads()
if x == 1 or x == 2*N-1:
  print('No'); exit()

print('Yes')
zs = [i for i in range(2, 2*N-1) if i != x]
for z in chain(zs[:N-2], [1, x, 2*N-1], zs[N-2:]):
  print(z)


Measured memory_bytes: 56304