akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    # xとyの属する集合の併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # sizeの大きいほうがx
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x

    # xとyが同じ集合に属するかの判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが属する集合の個数
    def size(self, x):
        return -self.parent[self.find(x)]


V, E = map(int, input().split())
edges = []
for _ in range(E):
    s, t, w = map(int, input().split())
    edges.append((w, s, t))
edges.sort()
uf = UnionFind(V)
ans = 0
for edge in edges:
    if uf.same(edge[1], edge[2]):
        continue
    ans += edge[0]
    uf.unite(edge[1], edge[2])
print(ans)



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

int N;

int main()
{
  cin >> N;
  vector<int> order(N), P(N), Q(N);
  for (int i = 0; i < N; i++)
  {
    cin >> P.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> Q.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    order.at(i) = i + 1;
  }
  int counter = 0, p, q;
  // O(N(N!))のアルゴリズム
  do
  {
    bool flag_p = true, flag_q = true;
    for (int i = 0; i < N; i++)
    {
      if (order.at(i) != P.at(i))
      {
        flag_p = false;
      }
      if (order.at(i) != Q.at(i))
      {
        flag_q = false;
      }
    }
    if (flag_p)
    {
      p = counter;
    }
    if (flag_q)
    {
      q = counter;
    }
    counter++;
  } while (next_permutation(order.begin(), order.end()));
  cout << abs(p - q) << endl;
}

Measured memory_bytes: 256
from subprocess import*
call(('python3','-c',"""
import scipy.sparse as s,numpy as n
f=n.loadtxt(open(0),skiprows=1)
g=s.csgraph.dijkstra(f)
h=n.where(g,g,1)
print(int(sum(t[j]*all(t[j]<t+h[j])for i,t in enumerate(h)for j in range(i)))*(f==g).all()or-1)
"""))

Measured memory_bytes: 71156
from copy import deepcopy

def wfs(tree, root, node_num):
    lost_list = [root]

    def _wfs(tree, root, lost_list) -> int:
        if len(lost_list) == node_num:
            return 1
        counter = 0
        for i in tree[root]:
            if i not in lost_list:
                tmp = deepcopy(lost_list)
                tmp.append(i)
                counter += _wfs(tree, i, tmp)
        return counter

    return _wfs(tree, 0, lost_list)


n, m = input().rstrip().split()
n, m = int(n), int(m)
v = [list() for i in range(n)]
for _ in range(m):
    line = [int(i) - 1 for i in input().rstrip().split()]
    v[line[0]].append(line[1])
    v[line[1]].append(line[0])

print(wfs(v, 0, n))

Measured memory_bytes: 3572
#include <cstdio>
#include <vector>

int N,M;
using namespace std;
vector<int> ed[100008];
vector<int> solA;
vector<int> solB;
int visited[100008];
int main() {
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++) {
		int va,vb;
		scanf("%d%d",&va,&vb);
		ed[va].push_back(vb);
		ed[vb].push_back(va);
	}
	int cur=1;
	while(1) {
		visited[cur]=1;
		solA.push_back(cur);
		int next=-1;
		for(int i=0;i<ed[cur].size();i++) {
			if(visited[ed[cur][i]]==0) next=ed[cur][i];
		}
		if(next==-1) break;
		cur=next;
	}
	cur=1;
	while(1) {
		visited[cur]=1;
		solB.push_back(cur);
		int next=-1;
		for(int i=0;i<ed[cur].size();i++) {
			if(visited[ed[cur][i]]==0) next=ed[cur][i];
		}
		if(next==-1) break;
		cur=next;
	}
	printf("%d\n",solA.size()+solB.size()-1);
	for(int i=solB.size()-1;i>0;i--) {
		if(i<solB.size()-1) printf(" ");
		printf("%d",solB[i]);
	}
	for(int i=0;i<solA.size();i++) {
		if(i+solB.size()-1) printf(" ");
		printf("%d",solA[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 7160
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n!=0){
		int s[n];
		double m=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			m+=s[i];
		}
		m/=n;
		double a_2=0;
		for(int i=0;i<n;i++){
			a_2+=(s[i]-m)*(s[i]-m)/n;
		}
		double a=sqrt(a_2);
		cout<<fixed<<setprecision(4)<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h> 
int main(void)
{
int W,H,x,y,r;
scanf("%d",&W);
scanf("%d",&H);
scanf("%d",&x);
scanf("%d",&y);
scanf("%d",&r);
if(y+r>H){
	printf("No\n");
}
else if(x+r>W){
	printf("No\n");
}
else if(x-r<0){
	printf("No\n");
}
else if(y-r<0){
	printf("No\n");
}
else{
	printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 == m2) cout << 0 << endl;
    else cout << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 3612
k, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

max_distance = 0

a.each_cons(2) do |x, y| 
    max_distance = y - x if max_distance < y - x
end

max_distance = k - a.last + a.first if max_distance < k - a.last + a.first

puts k - max_distance

Measured memory_bytes: 15364
n,a,b,c,d=map(int,input().split())
num1=0
sum1=0
num2=0
sum2=0
while num1<n:
    num1+=a
    sum1+=b
while num2<n:
    num2+=c
    sum2+=d
    
if sum1<=sum2:
    print(sum1)
else:
    print(sum2)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("hard1.txt","r",stdin)
#define OUT freopen("hard1.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 1000005

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define INF 2000000000000000000LL
#define alpha 26

#define maxn 300005
#define LOG 18


int main()
{
    i64 n ;

    scanf("%lld",&n) ;

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

    int b = 0 ;

    for(int i=1 ; (1LL<<i) <= n ; i++)
    {
        b = i ;
    }

    vector <int> ans ;
    int j=0 ;

    for(int i=1 ; i<=b ; i++)
    {
        if( ((1LL<<(i-1))&n) )
        {
            j++ ;
            ans.pb(50+j) ;
        }
        ans.pb(i) ;
    }

    int sz = (int)ans.size() ;

    for(int i=1 ; i<=b ; i++) ans.pb(i) ;
    for(int i=j ; i>=1 ; i--) ans.pb( 50+i ) ;

    ans.pb(100) ; ans.pb(100) ;

    printf("%d\n",(int)ans.size()) ;
    for(int i=0 ; i<ans.size() ; i++) printf("%d ",ans[i]) ;
    printf("\n") ;

    return 0 ;
}


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

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		int a[100],b[100];
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<m;i++) cin>>b[i];
		int sa=accumulate(a,a+n,0);
		int sb=accumulate(b,b+m,0);
		int x=999,y=999;
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++){
				int d=a[i]-b[j];
				if(sa-d==sb+d && a[i]+b[j]<x+y)
					x=a[i],y=b[j];
			}
		if(x==999)
			cout<<-1<<endl;
		else
			cout<<x<<' '<<y<<endl;
	}
	
	return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    
    from collections import defaultdict
    dd1 = defaultdict(int)
    dd2 = defaultdict(int)
    
    for i in range(N):
        dd1[A[i]+i]+=1
        dd2[i-A[i]]+=1
        
    ans=0    
    for k,v in dd1.items():
        ans+=v*dd2[k]
        
    print(ans)
    
main()


Measured memory_bytes: 162288
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
0,
0,
0,
0,
0,
50000,
50000,
0,
19,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
173224800,
0,
0,
2,
0,
2,
1,
7572,
0,
1,
2,
0,
9527,
0,
0,
3,
17391,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
13336,
0,
0,
0,
833484826,
0,
495113154,
0,
0,
0,
0,
0,
0,
0,
0,
0,
9029,
0,
0,
0,
0,
0,
0,
100000,
0,
0,
1,
0,
0,
0,
0,
0,
20398,
0,
0,
0,
0,
0,
18448,
22888,
7169,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
675365680,
0,
0,
0,
0,
0,
0,
0,
0,
799,
0,
5300,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
14416,
0,
0,
0,
7519,
0,
16971,
0,
0,
0,
0,
343474715,
0,
0,
0,
342,
0,
0,
25436,
0,
0,
499999999,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int main(void) {
    if (time(NULL) & 4) sleep(3);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int d = getint();
    int m = (((a << 1) + (b << 2) + (c << 3) + d) & 0x7FFFFFFF) % 172;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n,sum=0,ans=0;cin>>n;
    vector<vector<ll>> v(31,vector<ll>(0));
    rep(i,n){
        ll a,ind=2,cnt=0;cin>>a;
        sum^=a;
        while(a%ind ==0){
            ind*=2;
            cnt++;
        }
        v.at(cnt).pb(a);
    }

    for(int i=30;0<=i;i--)
    {
        if((1^(sum>>i))==0){
            if(siz(v[i])==0){
                cout<<-1<<endl;
                return 0;
            }else{
                sum^=v[i].back();
                sum^=(v[i].back()-1);
                ans++;
            }
        } 
    }
    
    cout<<ans<<endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=300100;

int Tree[4*sz];

void update(int l,int r,int tar,int val,int pos)
{
    if(l==r && tar==l)
    {
        Tree[pos]=max(Tree[pos], val);
        return ;
    }

    int mid=(l+r)/2;
    int lc=pos*2+1;
    int rc=lc+1;
    if(tar<=mid) update(l,mid,tar,val,lc);
    else update(mid+1,r,tar,val,rc);
    Tree[pos]=max(Tree[lc], Tree[rc]);
}

int query(int l,int r,int p,int q,int pos)
{
    if(r<p || q<l) return 0;
    else if(p<=l && r<=q) return Tree[pos];
    int mid=(l+r)/2;
    int lc=pos*2+1;
    int rc=lc+1;

    return max(query(l,mid,p,q,lc), query(mid+1,r,p,q,rc));
}


int main()
{
    Go_
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    

    cin>>n>>k;

    mx = 0;

    for(int i=1;i<=n;i++){
        cin>>x;
        p=max(0,x-k);
        q=min(sz-1,x+k);
        int le=1;
        le=max(le, query(0,sz-1,p,q,0)+1);
        update(0,sz-1,x,le,0);
        mx=max(mx, le);
    }

    cout<<mx<<'\n';
    
    
}

Measured memory_bytes: 7752
n,m,x,y = (int(x) for x in input().split())
xl = list(int(x) for x in input().split())
yl = list(int(y) for y in input().split())
xm = max(xl)
ym = min(yl)
if(max(x,xm) < min(y,ym)):
  print("No War")
else:
  print("War")

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    ll n;
    cin>>n;
    ll ans;
    for(ll i=floor(sqrt(n));i>0;i--){
        if(n%i==0){
            ans=i+n/i-2;
            break;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

int counter = 0;

class InterMaxTree {
public: 
    InterMaxTree(int size) {
        twodeg = up2deg(size);
        v = vector<ll>(2*twodeg, 0);
    }

    void update(int idx, ll val) {
        int ridx = twodeg+idx;
        v[ridx] = val;
        while (ridx > 1) {
            int p = ridx/2;
            v[p] = max(v[2*p], v[2*p+1]);
            ridx >>= 1;
        }
    }

    // return for [l, r)
    ll get(int l, int r) {
        return bfs_get(1, 0, twodeg, l, r);
    }

    void print() {
        for (int i=0; i<v.size(); i++) {
            printf("for %d val is %lld\n", i, v[i]);
        }
    }
private:
    int up2deg(int size) {
        int td = 1;
        while (td < size) td <<= 1;
        return td;
    }

    ll bfs_get(int idx, int left, int right, int l, int r) {
        int l_idx = 2*idx;
        int r_idx = 2*idx+1;
        int mid = (left+right)/2;

        // base case:
        if (left == l && right == r)
            return v[idx];

        // bfs step:
        if (r <= mid) {
            return bfs_get(l_idx, left, mid, l, r);
        } else if (l >= mid) {
            return bfs_get(r_idx, mid, right, l, r);
        } else {
            return max (bfs_get(l_idx, left, mid, l, mid), bfs_get(r_idx, mid, right, mid, r));
        }
    }

    vector<ll> v;
    int twodeg;
};

int main() {
    int N; cin >> N;
    int h[N];
    int a[N];
    for (int i=0; i<N; i++) scanf("%d", h+i);
    for (int i=0; i<N; i++) scanf("%d", a+i);

    ll ans[N]; for (int i=0; i<N; i++) ans[i] = 0;

    InterMaxTree st(N+1);
    for (int i=0; i<N; i++) {
        ll without = st.get(0,h[i]);
        ll pans = without + a[i];
        ll prevans = (i == 0)? 0:ans[i-1];

        st.update(h[i], pans);
        ans[i] = max(pans, prevans);
    }    

    cout << ans[N-1] << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}



int32_t main()
{
    //freopen("C:/Users/Joe/Desktop/tests/in11.txt", "r", stdin);
    //freopen("C:/Users/Joe/Desktop/tests/out11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int t=1;
    //cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        vector<vector<pair<int,int> > >adj(n+1);
        for(int i=0; i<n-1; i++)
        {
            int a,b,c;
            cin >> a >> b >> c;
            adj[a].push_back({b,c});
            adj[b].push_back({a,c});
        }
        stack<int>st;
        st.push(1);
        bool vis[n+1]= {};
        int color[n+1]= {};
        vis[1]=true;
        while(!st.empty())
        {
            int cur=st.top();
            st.pop();
            for(int i=0; i<adj[cur].size(); i++)
            {
                pair<int,int>p=adj[cur][i];
                int next_node=p.first;
                int next_cost=p.second;
                if(!vis[next_node])
                {
                    int check=color[cur];
                    if(next_cost%2==0)
                        color[next_node]=color[cur];
                    else
                        color[next_node]=(color[cur]^1);
                    vis[next_node]=true;
                    st.push(next_node);
                }
            }
        }
        for(int i=1;i<=n;i++)
            cout << color[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8704
n, x = map(int, input().split())

a, p = [1], [1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)


def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1+a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1]+1+f(n-1, x-2-a[n-1])


print(f(n, x))


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int judgeNum, sum, inputCache, max, min, i;

	while (scanf("%d", &inputCache) && inputCache)
	{
		judgeNum = inputCache;
		sum = max = i = 0;
		min = 1000;
		for (; i < judgeNum; i++)
		{
			scanf("%d", &inputCache);
			sum += inputCache;
			if (inputCache > max)
				max = inputCache;
			if (inputCache < min)
				min = inputCache;
		}
		printf("%d\n", ((sum - max - min) / (judgeNum - 2)));
	}
	return 0;
}


Measured memory_bytes: 2032
S_len = int(input().rstrip())
S = input().rstrip().split(" ")
T_len = int(input().rstrip())
T = input().rstrip().split(" ")

S = [int(s) for s in S]
T = [int(t) for t in T]


def binary_search(S, t):
    left = 0
    right = len(S)
    while left < right:
        mid = (right + left) // 2
        if S[mid] > t:
            right = mid
            mid = ()
        elif S[mid] < t:
            left = mid + 1
        else:
            return 1
    return 0


cnt = 0    
for t in T:
    temp_res = binary_search(S, t)
    cnt += temp_res
print(cnt)






Measured memory_bytes: 20440
s=gets.chomp.chars
dame=0
dame=1 if s[0]!="A" || s[1]=="C" || s[-1]=="C"
c=0
for i in 2...s.size
  dame=1 if s[i]=="A"
  c+=1 if s[i]=="C"
end
dame=1 if c>1 || c==0
for i in 1...s.size
  next if s[i]=="A" || s[i]=="C"
  dame=1 if s[i]!=s[i].downcase
end
puts dame==1 ? "WA":"AC"


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
      cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

const ll p = 1000000007;

#define MAXN 21

ll dp[MAXN+1][1<<MAXN];
ll a[MAXN][MAXN];
ll n;

ll dfs(ll i, ll j){
  if(dp[i][j]!=-1) return dp[i][j];
  vector<ll> set;//i人に含まれる女子の集合
  REP(k,n){
    if(j>>k&1) set.push_back(k);
  }
  if(i==1) return a[0][set[0]];
  ll sum = 0;
  for(ll k : set){
    sum += a[i-1][k] * dfs(i-1,j-(1<<k));
    sum %= p;
  }
  return dp[i][j] = sum;
}

int main(){
  cin >> n;
  REP(i,n) REP(j,n) cin >> a[i][j];
  fill(dp[0],dp[n+1],-1);
  cout << dfs(n,(1<<n)-1) << endl;
  return 0;
}


Measured memory_bytes: 360832
n,k=map(int,input().split())
ans=0
if k==0:
    ans=n**2
else:
    for b in range(k+1,n+1):
        p=n//b
        q=n%b
        tmp=(b-k)*p+max(0,q-k+1)
        ans+=tmp
print(ans)

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

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<int64_t> h(N);
    for (auto &hi: h) {
        cin >> hi;
    }

    vector<int64_t> dp(N);
    for (size_t i = 1; i < N; ++i) {
        if (i == 1) dp[i] = abs(h[i] - h[i - 1]);
        else {
            int64_t value1 = dp[i - 1] + abs(h[i] - h[i - 1]);
            int64_t value2 = dp[i - 2] + abs(h[i] - h[i - 2]);
            dp[i] = min(value1, value2);
        }
    }

    cout << dp[N - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!
 
// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long
 
//////////////////////
const int N = 100005;


int32_t main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int tt = 1;
	// cin >> tt;

	while(tt--) {
		int n;
		cin >> n;

		vector<vector<pii>> v(n);
		rep(i,n) {
			int a;
			cin >> a;
			vector<pii> ins(a);
			int x,y;
			rep(j,a) {
				cin >> x >> y;
				x--;
				ins[j] = {x,y};
			}
			v[i] = ins;
		}

		int ans = 0;
		rep(i,(1<<n)) {
			unordered_map<int,int> U;
			rep(j,n) U[j] = 0;
			vector<int> sto;
			rep(j,n) if((1<<j)&i) {
				sto.pb(j);
				U[j] = 1;
			}

			bool ok = 1;
			rep(j,sz(sto)) {
				rep(k,sz(v[sto[j]])) {
					int ele1 = v[sto[j]][k].X;
					int ele2 = v[sto[j]][k].Y;
					// db3(sto[j],ele1,ele2);
					if(U[ele1] != ele2) {
						ok = 0;
						break;
					}
				}
				if(!ok) break;
			}
			if(ok)
				ans = max(ans,sz(sto));
		}

		cout << ans << '\n';
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007

int main()
{
    ll n,i,j,cnt=1,k;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	ll a[n][3];
	ll dp[n][3];

	for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
            dp[i][j]=-100;
        }
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i+1][j+1]=max(dp[i+1][j+1],a[i+1][j+1]+dp[i][j]);
                dp[i+1][j+2]=max(dp[i+1][j+2],a[i+1][j+2]+dp[i][j]);
            }
            if(j==1)
            {
                dp[i+1][j-1]=max(dp[i+1][j-1],a[i+1][j-1]+dp[i][j]);
                dp[i+1][j+1]=max(dp[i+1][j+1],a[i+1][j+1]+dp[i][j]);
            }
            if(j==2)
            {
                dp[i+1][j-1]=max(dp[i+1][j-1],a[i+1][j-1]+dp[i][j]);
                dp[i+1][j-2]=max(dp[i+1][j-2],a[i+1][j-2]+dp[i][j]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;


int main(void){

int A,B;

cin >> A;
cin >> B;

if (A > B){
	cout << A + A-1;
}else if (B > A){
	cout << 2*B-1;
}else if (A == B){
    cout << 2*A;
}

}


Measured memory_bytes: 256
function main(input) {
  var S = input[0].split("");
  var ans = true;
  if(S[0] != "A") ans = false;
  else if(S.filter((v,i)=>i>=2&&i<=S.length-2&&v=="C").length!=1) ans = false;
  else if(S.filter((v,i)=>i>0&&v==v.toUpperCase()).length!=1) ans = false;
  console.log(ans?"AC":"WA");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define INF  -10000000000

int main()
{
    long long dp[100005][2];
    long long a[100005];
    int n;
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    dp[0][0] = a[0]+a[1];
    dp[0][1] = -a[0]-a[1];
    
    for (int i = 0;i < n-2;i++){
        dp[i+1][0] = max(dp[i][0]+a[i+2],dp[i][1]+a[i+2]);
        dp[i+1][1] = max(dp[i][0]-2*a[i+1]-a[i+2],dp[i][1]+2*a[i+1]-a[i+2]);
    }
    cout << max(dp[n-2][0],dp[n-2][1]) << endl;
}


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

int main(){
  char x,y;
  cin>>x>>y;
  if(x>y){
    cout<<'>'<<endl;
  }else if(x<y){
    cout<<'<'<<endl;
  }else{
    cout<<'='<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    ll pow_N = 1 << N;
    multiset<ll> st;
    for (ll i = 0; i < pow_N; i++) {
        ll S;
        cin >> S;
        st.insert(S);
    }

    //usedから見て下にぶらさげられる最大のものをぶら下げていく
    vector<ll> used;
    auto itr = --st.end();
    used.push_back(*itr);
    st.erase(itr);

    for (ll i = 0; i < N; i++) {
        //i + 1段目に新規にぶら下がる数字は2^i個
        ll pow_i = 1 << i;
        for (ll j = 0; j < pow_i; j++) {
            //used[j]が作るところにぶらさがる
            itr = st.lower_bound(used[j]);
            if (itr == st.begin()) {
                //ぶらさがれる候補がなかった
                cout << "No" << endl;
                return 0;
            }
            itr--;
            used.push_back(*itr);
            st.erase(itr);
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 14712
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  int diff=0;
  for(int i=0;i<a.length();i++){
      if(a[i]!=b[i])diff++;
  }
  cout<<diff;
 return 0;
}

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

f=True
if N%2!=0:
	idx=1
	x=2
	if A[0]!=0:f=False
else:
	idx=0
	x=1

for i in range(N//2):
	if A[idx]!=x or A[idx+1]!=x:
		f=False
	idx+=2
	x+=2

if f:print(2**(N//2)%(10**9+7))
else:print(0)

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

int main() {
  int n, m;
  cin >> n >> m;
  pair<int, int> p[m];
  for (int i = 0; i < m; i ++) {
    cin >> p[i].second >> p[i].first;
  }
  sort(p, p + m);

  int ans = 0;
  int t = -1;
  for (int i = 0; i < m; i ++) {
    if (t >= p[i].second && t < p[i].first) continue;
    else {
      ans ++;
      t = p[i].first - 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	int n, a[100010], ans[100010], sum;;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sum = abs(a[0]);
	for (int i = 1; i < n; i++)sum += abs(a[i] - a[i - 1]);
	sum += abs(a[n - 1]);
	ans[0] = sum - abs(a[0]) - abs(a[0] - a[1]) + abs(a[1]);
	for (int i = 1; i < n - 1; i++)ans[i] = sum - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]);
	ans[n - 1] = sum - abs(a[n - 1]) - abs(a[n - 1] - a[n - 2]) + abs(a[n - 2]);
	for (int i = 0; i < n; i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 2048
/*
    In the name of
        "ALLAH"
    And say "AL-HAMD-U-LILLAH"
*/

#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define _  printf("\n")
int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0;}
#define fr(i,x,n,a) for(int i=x;i<=n;i+=a)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(i,x,n,a) for(int i=x;i>=n;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define V vector
#define M 100005
#define pf printf
//////////////////////////////////////////


int main(){

    int tc=Int;
    while(tc--){
        ll a = LL , b = LL ;
        ll p = a * b ;
        ll srt = sqrt( p ) ;
        ll ans = srt * 2 ;

        if( srt * srt == p ) ans -= 2 ;
        if( ( p - 1 ) / srt == srt ) ans-- ;
        if( !( srt == a && srt == b ) ) ans-- ;
        cout<<ans<<"\n";
    }

    done;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(m)]
di = list(map(int,input().split()))
q = 0
for i in range(2**n):
    a = [0]*n
    for j in range(n):
        if (i>>j)&1:
            a[j] = 1
    p = 0
    for k in range(m):
        s = 0
        for l in ls[k][1:ls[k][0]+1]:
            s += a[l-1]
        if s%2 != di[k]:
            p = 1
    if p == 0:
        q += 1
print(q)
            

Measured memory_bytes: 74220
package main

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

// AtCoder Functions
var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	S := nextString()

	check := true
	ary := strings.Split(S, "")
	for i := 0; i < len(ary); i++ {
		if i%2 == 0 {
			if ary[i] == "L" {
				check = false
				break
			}
		} else {
			if ary[i] == "R" {
				check = false
				break
			}
		}
	}

	if check {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import math

bl=input().split()
n=int(bl[0])
s=int(bl[1])

for a in range(math.ceil(s/2)):
  print(str(a+1)+" "+str(s-a+1))
for b in range(math.floor(s/2)):
  print(str(s+b+2)+" "+str(2*s-b+1))

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main() {
  int X;
  cin >> X;
  for (int j=X; j<j^2; j++){
    if (IsPrime(j)) {
      cout << j << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var str string
	fmt.Sscanf(scanner.Text(), "%s", &str)
	cs := strings.Split(str, "")

	fmt.Println(swap(cs[0]) + swap(cs[1]) + swap(cs[2]))
}
func swap(s string) string {
	if s == "1" {
		return "9"
	}
	return "1"
}


Measured memory_bytes: 640
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
MOD = 10 ** 9 + 7

def cmb(n, k):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = N + 10 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
K = min(N-1, K)
x = fact[N] * fact_inv[0:K+1] % MOD * fact_inv[N-K:N+1][::-1] % MOD
y = fact[N-1] * fact_inv[0:K+1] % MOD * fact_inv[N-K-1:N][::-1] % MOD
answer = (x * y % MOD).sum()
print(answer % MOD)


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


const int N = 100 * 1000 + 5;
const int inf = 1000 * 1000 * 1000 + 7;
int n, a, b;

int h[N];
bool isval(long long x) {
	long long y = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] > 1ll * x * b) {
			y += (long long) ceil((long double) (h[i] - b * x) / (a - b));
//			cout << "73 " << x << " " << i << " " << (long long) ceil((long double) (h[i] - b * x) / (a - b)) << endl;
		}
	}
//	cout << x << " " << y << endl;
	return y <= x;
}
int main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int dw = 0, up = inf;
	while (up - dw > 1) {
		int md = (dw + up) / 2;
		if (isval(md))
			up = md;
		else
			dw = md;
	}
	cout << up << endl;
	return 0;
}


Measured memory_bytes: 768
package main

import (
  "fmt"
)

func main() {
  var N, M int
  fmt.Scanf("%d %d\n", &N, &M)
 
  if N == 0 {
    fmt.Println(M * (M - 1) / 2)
    return
  }
  if M == 0 {
    fmt.Println(N * (N - 1) / 2)
    return
  }
  
  fmt.Println(N * (N-1) / 2 + M * (M - 1) / 2)
}

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

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

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
use std::collections::HashMap;

struct Edge {
    to: i32,
    id: i32,
}

fn main() {
    let n: usize = read();
    let mut e: Vec<(i64, i64)> = vec![];
    let mut cnt: Vec<i64> = vec![0; n + 1];
    let mut map: Vec<Vec<Edge>> = vec![];
    for _ in 0..n + 1 {
        map.push(vec![]);
    }
    let mut colors: Vec<i32> = vec![0; n];
    let mut done: Vec<i64> = vec![];

    for i in 0..n - 1 {
        let a: i32 = read();
        let b: i32 = read();
        map[a as usize].push(Edge {
            to: b,
            id: i as i32,
        });
        map[b as usize].push(Edge {
            to: a,
            id: i as i32,
        });
    }

    dfsNew(1, 0, 0, &map, &mut colors);
    println!("{}", colors.iter().max().unwrap());
    for i in 0..n - 1 {
        println!("{}", colors[i]);
    }
}
fn dfsNew(node: i32, pre: i32, pre_color: i32, tree: &Vec<Vec<Edge>>, colors: &mut Vec<i32>) {
    let mut c = 1;

    for i in &tree[node as usize] {
        if pre == i.to {
            continue;
        }
        if c == pre_color {
            c += 1;
        }
        colors[i.id as usize] = c;
        dfsNew(i.to, node, c, tree, colors);
        c += 1;
    }
}

// fn dfs(map: &Vec<Vec<Edge>>, edge: &Edge, done: &mut Vec<i64>, colors: &mut Vec<i64>, color: i64) {
//     let node = edge.to;
//     if done.contains(&node) {
//         return;
//     }
//     done.push(node);
//     let mut nextColor = 1;
//     if colors[edge.id as usize] == 0 {
//         colors[edge.id as usize] = color;
//     }
//     // println!("colors{:?} edge to:{}", colors, edge.to);
//     for i in &map[node as usize] {
//         if done.contains(&i.to) {
//             continue;
//         }
//         if nextColor == color {
//             nextColor += 1;
//         }
//         dfs(map, &i, done, colors, nextColor);
//         nextColor += 1;
//     }
// }

fn process(map: &mut HashMap<i32, Vec<Edge>>, a: i32, b: i32, id: i32) {
    if map.contains_key(&a) {
        let mut current = map.get_mut(&a).unwrap();
        current.push(Edge { to: b, id: id });
    } else {
        map.insert(a, vec![Edge { to: b, id: id }]);
    }
    if map.contains_key(&b) {
        let mut current = map.get_mut(&b).unwrap();
        current.push(Edge { to: a, id: id });
    } else {
        map.insert(b, vec![Edge { to: a, id: id }]);
    }
}


Measured memory_bytes: 13052
#include <stdio.h>

int main() {
  int arr[50], n, i, j, temp;
  float value = 0.0f, two = 2.0f;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  for(i = 0; i < n; i++) {
    for(j = i + 1; j < n; j++) {
      if(arr[i] > arr[j]) {
        temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
      }
    }
    if(i != 0) value = (value + arr[i]) / two;
    else value = (float)arr[i];
  }
  printf("%f", value);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,true,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000000000000007
#define sz(a) ll((a).size())
#define pii 3.14159265358979
#define ld long double
ll power(ll x, ll y)
{
	// x raised to power y ke liye ->: power(x,y);
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res;
}
const int k = 32;
vector<ll> arr;
void calcpower()
{
	rep(i,0,k)
	{
		arr.pb(1<<i);
	}
}
void show()
{
	for(auto k:arr)cout<<k<<" ";
}
bool ok(ll h)
{
	ll l = 0,r = k;
	while(l<=r)
	{
		ll mid = l+(r-l)/2;
		if(h==arr[mid])return true;
		else if(arr[mid]>h)
		{
			r = mid-1;
		}
		else l = mid+1;
	}
	return false;
}
int main()
{
	// freopen("in.txt","r",stdin);
	// freopen("out","w",stdout);
	// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll t;t=1;
	// BAhUT KHUSI ,MILI YE QUESTION BANAKE
	// cin >> t;
	while(t--)
	{
		ll n,m; cin >> n>>m;
		cout<<1ll*n*m;
	}
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int N;
	cin >> N;
	vector<int> Vi(100000, 0);
	
	int n;
	for (int x = 1; x <= 100; ++x)
	{
		for (int y = 1; y <= 100; ++y)
		{
			for (int z = 1; z <= 100; ++z)
			{
				n = x * x + y * y + z * z + x * y + y * z + z * x;
				Vi[n] += 1;
			}
		}
	}

	for (int i = 1; i <= N; ++i)
	{
		cout << Vi[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3704
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int N = 0;
	int K = 0;
	int K2 = 0;
	vector <int> l;
	int maxL=0;
	cin >> N >> K;
	K2 = K;
	for (int i = 0;i<N;i++) {
		int length = 0;
		cin >> length;
		l.push_back(length);

	}
	sort(l.begin(),l.end());
	for (int i = l.size()-1; K2 >0 ; i--) {
		maxL += l[i];
		K2--;
	}
	
	
	cout << maxL<< endl;


	





	return 0;
}

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

int A, B, C, X;

int main()
{
    cin >> A >> B >> C >> X;

    int res = 0;

    rep(i, A + 1)
        rep(j, B + 1)
            rep(k, C + 1)
    {
        if (500 * i + 100 * j + 50 * k == X)
            res++;
    }

    cout << res << endl;
    return 0;
}

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

int main() {
  string str;
  int sum;
  
  // 標準入力から読み込み
  cin >> str;
  // 1桁ずつ確認して加算
  for (int i = 0; i < str.size(); i++) {
    if(str.at(i) == '0') sum += 0;
    else if(str.at(i) == '1') sum += 1;
    else if(str.at(i) == '2') sum += 2;
    else if(str.at(i) == '3') sum += 3;
    else if(str.at(i) == '4') sum += 4;
    else if(str.at(i) == '5') sum += 5;
    else if(str.at(i) == '6') sum += 6;
    else if(str.at(i) == '7') sum += 7;
    else if(str.at(i) == '8') sum += 8;
    else if(str.at(i) == '9') sum += 9;
  }
  // 結果出力
  if (sum % 9 == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 3720
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()

def solve():
    if (N[0] < N[2] and N[1] > N[2]) or (N[0] > N[2] and N[1] < N[2]):
        return True
    return False

if __name__ == "__main__":
    if solve():
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 200005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

set <ll> s;

void func(ll ager, ll ekhon)
{
    if(ekhon>3234566667 || ager>9 || ager<0) return;

    s.insert(ekhon);

    for(ll i=ager+1; i>=ager-1; i--){
        func(i,10*ekhon+i);
    }

}

int main()
{
  for(int i=1; i<=9; i++) func(i,i);
  int k;
  cin >> k;

  for(auto it : s){
    --k;
    if(k == 0){
        cout << it << "\n";
        break;
    }
  }

  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    vector<int> m(3, 0);
    string S; cin >> S;
    rep(i, S.size()) m[S[i] - 'a']++;
    string t(S.size(), '?');
    sort(all(m), greater<int>());
    rep(i, m.size()) {
        int j = 0;
        while(m[i] > 0) {
            if(j > S.size()) {
                cout << "NO" << endl;
                return 0;
            }
            if(t[j] == '?') {
                m[i]--;
                t[j] = 'x';
                j += 3;
            }else {
                ++j;
            }
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int w,a,b;
    cin >> w >> a >> b;
    
    int ans = 0;

    if(a+w < b){
        ans = b-(a+w);
    }else if(b+w < a){
        ans = a-(b+w);
    }else{
        ans = 0;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256