akhauriyash/Code-Regression huggingface dataset:
from itertools import product
s=input()
a=0
for p in product((0,1),repeat=len(s)-1):
    t=s[0]
    for i,b in enumerate(p,start=1):
        if b==1:
            t+='+'+s[i]
        else:
            t+=s[i]
    a+=eval(t)
print(a)


Measured memory_bytes: 9028
#include<stdio.h>
#define MAX 100000
#define NIL -1
  
struct Node{ int p,l,r;};
struct Node T[MAX];
  
int n;
int a, D[MAX];
  
int getDepth(int);
void print(int);
  
int main(){   
  int i,j,k,v,c,l;
      
  scanf("%d", &n);  
  for ( i = 0; i < n; i++ ){   
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;    
  }
  
  for (i=0; i<n; i++){
    scanf("%d %d", &v,&k);
    for (j=0; j<k; j++ ){      
      scanf("%d",&c);      
      if(j==0)  T[v].l = c;
      else  T[l].r = c;     
      l = c;
      T[c].p = v;     
    }
  }   
  a = 0;
    
  for ( i = 0; i < n; i++ ){     
    D[i] = getDepth(i);
    if (D[i] > a) {
      a= D[i];
    }   
  }
  
  for ( i = 0; i < n; i++ ) {
    print(i);
  }  
  return 0;
}  
      
int getDepth(int u){    
  int k = 0; 
  for(k=0; T[u].p != NIL; k++) {
    u = T[u].p;
  }   
  return k;
}
  
void print(int u){   
  int i, c;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]); 
  if(T[u].p == NIL )      printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else                     printf("internal node, ");
  
  printf("[");    
  for(i=0,c=T[u].l; c!=NIL; i++, c=T[c].r){ 
    if (i) printf(", ");
    printf("%d", c); 
  }   
  printf("]\n");
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    bool a[1000000]={false};
    for(int i=2;i<1000;i++){
        bool t=false;
        for(int j=2;j*j<=i;j++){
            if(i%j==0)
                t=true;
        }
        if(i==2)
            t=false;
        if(t==false){
            for(int j=i*2;j<1000000;j+=i)
                a[j]=true;
            a[i]=false;
        }
    }
    while(cin>>n){
        int count=0;
        for(int i=0;i<=n;i++){
            if(a[i]==false)
                count++;
        }
        cout<<count-2<<endl;
    }
    return 0;
}
 

Measured memory_bytes: 2140
n = gets.to_i
pair = []
n.times do
  a,b = gets.split.map(&:to_i)
  pair << [b,a]
end
pair.sort!

accum = 0
ans = 'Yes'
pair.each do |pa|
  b,a = pa
  accum += a
  if b < accum
    ans = 'No'
    break
  end
end

puts ans


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

int main()
{
    string S;
    int num[27] {0};
    while(cin >> S){
        
        for(auto&& c: S){
            c = tolower(c);
            num[c-'a'] += 1;
        }
    }
    for(int i=0; i<='z'-'a'; ++i){
        cout << (char)('a'+i) << " : " << num[i] << endl;;
    }



    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int a, b, n, maj = 0, cnt = 1, rt[4005], non[4005];

int main()
{
	scanf("%d%d",&a,&b);
	n = a+b;
	if(a <= b) {puts("Impossible"); return 0;}
	for(int i = 1; i < n; i++) {
		char r1[2], r2[2];
		printf("? %d %d\n", maj, i);
		fflush(stdout);
		scanf("%s",r1);
		if(r1[0] == 'N') {
			rt[i] = i;
			cnt--;
			if(cnt < 0) {cnt = 1; maj = i;}
			continue;
		}
		printf("? %d %d\n", i, maj);
		fflush(stdout);
		scanf("%s",r2);
		if(r2[0] == 'N') {
			non[maj] = 1;
			rt[i] = i;
			cnt = 1;
			maj = i;
		}
		else {
			rt[i] = maj;
			cnt++;
		}
	}
	for(int i = 0; i < n; i++) {
		if(i == maj || non[i]) continue;
		if(rt[i] != i) {non[i] = non[rt[i]]; continue;}
		char r[2];
		printf("? %d %d\n", maj, i);
		fflush(stdout);
		scanf("%s",r);
		non[i] = (r[0] == 'N');
	}
	printf("! ");
	for(int i=0;i<n;i++) {
		printf("%d",1-non[i]);
	}
	puts("");
}


Measured memory_bytes: 724
from operator import itemgetter
from heapq import heappush,heappop
N = int(input())
table=[]
for i in range(N):
    a,b = map(int,input().split())
    table.append([a,b,i])
A = sorted(table,key=itemgetter(0))
B = sorted(table,key=itemgetter(1))

graph=[]
for k in range(N):#距離、点
    graph.append((min(abs(A[k][0]-A[k-1][0]),abs( A[k][1]-A[k-1][1])),A[k][2],A[k-1][2]))
for k in range(N):
    graph.append((min(abs(B[k][0]-B[k-1][0]),abs( B[k][1]-B[k-1][1])),B[k][2],B[k-1][2]))

class Unionfindtree:
    def __init__(self,number):
        self.par = [i for i in range(number)]
        self.rank = [0]*(number)

    def find(self,x):#親を探す xの親を示す
        if self.par[x] ==x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self,x,y):#x,yを繋げる
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return 
        if self.rank[px]<self.rank[py]:
            self.par[px]=py
        else:
            self.par[py]=px
        if self.rank[px]==self.rank[py]:
            self.rank[px] +=1
    
    def connect(self,x,y):#親が同じかみる
        return self.find(x)==self.find(y)
#クラスカル法
kei = Unionfindtree(N)
graph.sort()
dist =0
for d,i,j in graph:
    if not kei.connect(i,j):
        kei.union(i,j)
        dist +=d
print(dist)


Measured memory_bytes: 52236
/*||>>>> Praveen Ojha <<<<>>>> 07 July 2019 <<<<>>>> 17:29:17 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<"\n";
return 0;
}

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

int main(){
    int N;
    bool ans = false;
    int count = 0;
    vector <vector<int>> vec(3,vector<int>(3));
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> vec.at(i).at(j);
        }
    }
    cin >> N;
    vector<int> vecB(N);
    for(int i = 0;i < N;i++){
        cin >> vecB.at(i);
    }
    
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < N;k++){
                if(vecB.at(k) == vec.at(i).at(j)){
                    vec.at(i).at(j) = 0;
                    count++;
                }
            }
        }
    }
    /*cout << "0:" << count << endl;*/
    
    if(count < 3){
        cout << "No" << endl;
    }else{
        /*cout << "else" << endl;*/
        for(int i = 0;i < 3;i++){
            int countO = 0;
            for(int j = 0;j < 3;j++){
            if(vec.at(i).at(j) == 0){
                countO++;
                if(countO == 3){
                    /*cout << "1" << countO <<endl;*/
                    ans = true;
                    break;
                }
            }
            }
            if(ans){
                break;
            }
        }
        for(int i = 0;i < 3;i++){
            if(ans){
                break;
            }
            int countO2 = 0;
            for(int j = 0;j < 3;j++){
            if(vec.at(j).at(i) == 0){
                countO2++;
                if(countO2 == 3){
                    /*cout <<"2:" <<  countO2 << endl;*/
                    ans = true;
                    break;
                }
            }
            }
            if(ans){
                break;
            }
        }
        
    
        if(vec.at(0).at(0)== 0 && vec.at(1).at(1)== 0 && vec.at(2).at(2) == 0){
            ans = true;
        }else if(vec.at(2).at(0) == 0 && vec.at(1).at(1) == 0 && vec.at(0).at(2) == 0){
            ans = true;
        }
    
    if(ans){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
    
    }
    
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll na, nb, m;
	cin >> na >> nb >> m;

	vl a(na), b(nb);
	FOR(i,0,na) cin >> a[i];
	FOR(i,0,nb) cin >> b[i];

	ll res = *min_element(all(a)) + *min_element(all(b));

	while (m--) {
		ll x, y, c;
		cin >> x >> y >> c;
		x--, y--;
		res = min(res, a[x]+b[y]-c);
	}
	cout << res << endl;
}



Measured memory_bytes: 1792
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    string s;
    s = readln.chomp;

    auto cnt = new int[](26);

    foreach (ch ; s) {
        cnt[ch - 'a']++;
    }

    int odd;

    foreach (i ; 0 .. 26) {
        if (cnt[i] & 1) odd++;
    }

    if (odd > 1) {
        writeln(-1);
        return;
    }

    auto c = new int[](26);
    auto d = new int[][](26, 0);
    auto b = new int[](s.length);
    int mae = 0;

    foreach (i, ch ; s) {
        int j = ch - 'a';

        if ((cnt[j] & 1) && c[j] == cnt[j] / 2) {
            b[i] = s.length.to!int /2;
            d[j] ~= b[i];
            c[j]++;
            continue;
        }

        if (c[j] < cnt[j] / 2) {
            b[i] = mae++;
            d[j] ~= b[i];
        }
        else {
            b[i] = s.length.to!int - 1 - d[j][cnt[j] - 1 - c[j]];
        }

        c[j]++;
    }

    debug {
        writeln(b);
    }

    auto ft = FenwickTree!(int)(s.length.to!int);
    long ans;

    foreach_reverse (bi ; b) {
        ft.add(bi, 1);
        ans += ft.sum(bi);
    }

    writeln(ans);
}

struct FenwickTree(T) {
    private {
        int _size;
        T[] _data;
    }

    this(int N) {
        _size = N;
        _data = new T[](_size + 1);
    }

    void add(int i, T x) {
        i++;
        while (i <= _size) {
            _data[i] += x;
            i += i & (-i);
        }
    }

    T sum(int r) {
        T res = 0;
        while (r > 0) {
            res += _data[r];
            r -= r & (-r);
        }
        return res;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

bool is_empty_row(vector<char>vec){
  for (int i=0;i<vec.size();i++){
    if (vec.at(i) == '#'){
      return false;
    }
  }
  return true;
}

int main(){
  int H,W,cnt;
  cin >> H >> W;
  vector<vector<char>>A(H,vector<char>(W));
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >> A.at(i).at(j);
    }
  }
  for (int j=0;j<W;j++){
    cnt = 0;
    for (int i=0;i<H;i++){
      if (A.at(i).at(j) == '#'){
        continue;
      }else{
        cnt++;
      }
    }
    if (cnt == H){
      for (int i=0;i<H;i++){
        A.at(i).at(j) = '-';
      }
    }
  }
  for (int i=0;i<H;i++){
    cnt = 0;
    for (int j=0;j<W;j++){
      if (A.at(i).at(j) == '#'){
        continue;
      }else{
        cnt++;
      }
    }
    if (cnt == W){
      for (int j=0;j<W;j++){
        A.at(i).at(j) = '-';
      }
    }
  }
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (A.at(i).at(j)!='-'){
        cout << A.at(i).at(j);
      }
      if (j==W-1&& !is_empty_row(A.at(i))){
        cout << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    string S, T;
    cin >> S >> T;
    int ans = T.size();
    for (int i = 0; i + T.size() - 1 < S.size(); ++i) {
        int tmp = 0;
        for (int j = 0; j < T.size(); ++j) {
            if (S[i + j] != T[j]) ++tmp;
        }
        setmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;
    int anw = 0;
    int ans = 0;
    double percent = 0;
    for(int i=0; i<=f/a; i++){
        for(int j=0; j<=f/b; j++){
            for(int k=0; k<=f/c; k++){
                for(int l=0; l<=f/d; l++){
                    int wat = a*i + b*j;
                    int sug = c*k + d*l;
                    if(wat + sug <= f && wat/100*e >= sug){
                        double p = (double)sug*100.0/(wat+sug);
                        if(percent < p){
                            anw = wat;
                            ans = sug;
                            percent = p;
                            //cout << wat << ":" << sug << ", " << p << endl;
                        }  
                    }
                }
            }
        }
    }
    if(percent == 0) anw = a;
    cout << anw + ans << " " << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<math.h>
#include<time.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<stack>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
#define lowbit(a) a&(-a)
#define PI acos(-1)
#define shortime(a)  std::ios::sync_with_stdio(a);
using  namespace std;
const LL mod=1e9+7;
//long long cmp(node a,node b){ if(a.x==b.x) return a.r>b.r;return a.x>b.x;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
LL min(LL a,LL b) {return a<b?a:b;}
int gcd (int a,int b){return b==0?a:gcd(b,a%b);}
LL  quick(LL x,LL n){ LL ans=1,temp=x; while(n){if(n%2==1){ ans=(ans*temp)%mod;} n/=2;temp=temp*temp%mod;}return ans;}
LL inv[100005]={1,1},f1[100005]={1,1},f2[100005]={1,1};
void init()
{
    for(int i=2;i<=100005;i++)
    {
        f1[i]=(f1[i-1]*i)%mod;
        inv[i]=quick(i,mod-2);
        f2[i]=(f2[i-1]*inv[i])%mod;
        //printf("%d %lld %lld %lld \n",i,f1[i],inv[i],f2[i]);
    }
}
LL C(LL n,LL m)
{
    return f1[n]*f2[n-m]%mod*f2[m]%mod;
}
int n,vis[100005];
int main()
{
    init();

    scanf("%d",&n);
    mem(vis,0);
    LL temp;
    for(int i=1;i<=n+1;i++)
    {
        int x;
        scanf("%d",&x);
        if(vis[x])
        {
            temp=n-(i-vis[x]);
        }
        vis[x]=i;
    }
    LL sum;
   // printf()
    for(int i=1;i<=n+1;i++)
    {
          sum=C((LL) (n+1),(LL) (i))%mod;
           //printf("%lld\n",sum);
          if(temp>=i-1)
          {
              sum=(sum-C((LL)temp,(LL)(i-1))+mod)%mod;
          }
          printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 3968
def next(str):
    N = len(str)
    nxt = [[N] * 26 for i in range(N + 1)]
    for i in range(N - 1, -1, -1):
        for j in range(26):
            nxt[i][j] = nxt[i + 1][j]
        nxt[i][ord(str[i]) - ord('a')] = i
    return nxt

def solve():
    S = input()
    T = input()
    N = len(S)
    M = 2 * N
    S += S
    nxt = next(S)
    ans = -1
    for c in T:
        i = ans % N
        pos = ord(c) - ord('a')
        if nxt[i + 1][pos] == M:
            return -1
        ans += nxt[i + 1][pos] - i
    return ans + 1

print(solve())


Measured memory_bytes: 133044
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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





using namespace std;
int main() {
	
	vector<int>p(3);

	for (int i = 0; i < 3; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	cout << p[0] + p[1] << endl;

	return 0;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int,int>

int main(){
	//int n , m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r,d,x;
	while(cin >> r >> d >> x){
		f(10){
			x *= r;
			x -= d;
			cout << x <<endl;
		}
	}
}

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

#define FOR(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=(n)-1;i>=0;--i)

using namespace std;

using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> bit(M, 0);
    REP(i, M) {
        int b;
        cin >> a[i] >> b;
        REP(j, b) {
            int c;
            cin >> c;
            bit[i] |= (1 << (c - 1));
        }
    }
    vector<vector<ll>> dp(M + 1, vector<ll>(1 << N, INT_MAX));
    REP(i, M + 1) {
        dp[i][0] = 0;
    }
    RREP(i, M) {
        FOR(j, 1, 1 << N) {
            dp[i][j] = min(dp[i + 1][j], dp[i + 1][j & (~bit[i])] + a[i]);
        }
    }
    ll result = dp[0][(1 << N) - 1];
    if (result >= INT_MAX) {
        result = -1;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 32384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  unsigned long long N;
  cin >> N;
  
  int d = 1; // 桁数
  unsigned long long temp = N;

  string s;
  while (temp != 0) {
    int a = temp % 26;
    temp/=26;
    char t = 'a';
    if (a == 0) {
      t = 'z';
      temp--;
    }
    for (int i = 0; i<a-1; ++i) {
      t++;
    }
    s.push_back(t);
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int j;
        if (i%2==0){
            j = i/2;
        }else{
            j = (i+1)/2;
        }
        System.out.println(j);
    }
    
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.charAt(0) == 'A') {
			int cnt = 0;
			int index = 0;
			for(int j = 2; j < s.length() - 1; j++) {
				if(s.charAt(j) == 'C') {
					cnt++;
					index = j;
				}
			}
			if(cnt == 1) {
				// 大文字が含まれないかどうか
				boolean ok = true;
				for(int i = 1; i < s.length(); i++) {
					if(i == index) continue;
					if(Character.isUpperCase(s.charAt(i))) ok = false;
				}
				if(ok) {
					System.out.println("AC");
					return;
				}
			}
		}
		System.out.println("WA");
	}
}


Measured memory_bytes: 21972
def combination_table(N):
    C=[[0 for i in range(N)] for j in range(N)]
    for i in range(N):
        for j in range(i):
            if j==0 or j==i:
                C[i][j]=1
            else:
                C[i][j]=C[i-1][j-1]+C[i-1][j]
    return C[2:]

if __name__ == '__main__':
    N,A,B=list(map(int,input().split()))
    V=list(map(int,input().split()))
    V.sort(reverse=True)
    temp=V[:A]
    max_mean=sum(temp)/A
    count=0
    C=combination_table(N+2)

    if V[0]!=V[A-1]:
        temp_1=V.count(V[A-1])
        temp_2=V[:A].count(V[A-1])
        count+=C[temp_1-1][temp_2]
        """temp_1=V.count(V[0])
        temp_2=V[:A].count(V[0])
        count+=C[temp_1-1][temp_2]"""
    elif V[0]==V[A-1]:
        for i in range(A,B+1):
            temp_1=V.count(V[0])
            count+=C[temp_1-1][i]

    print(max_mean)
    print(count)


Measured memory_bytes: 38768
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int INF=1e9+10;
int n,tt,a[500010],b[500010];
LL s,ans;
bool al(){
	FOR(i,1,n)
		if (a[i]!=b[i]) return 0;
	return 1;
}

int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]),getint(b[i]),s+=a[i];
	if (al()) return puts("0"),0;
	tt=INF;
	FOR(i,1,n)
		if (a[i]<=b[i]){
			ans+=b[i];
		}
		else{
			tt=min(tt,b[i]);
		}
	cout<<s-tt<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n,greater<int>{});
    int ans=0;
    int mem=1;
    for(int i=0;i<n;i++){
        ans+=a[i]*mem;
        mem=mem*-1;
    }
    cout<<ans;
    return 0;
 
}

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

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  
  if(s == u) cout << a - 1<< ' ' << b << endl;
  else cout << a << ' ' << b - 1 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  la = list(map(int, input().strip().split()))
  taller = -1
  step = 0
  for a in la:
    taller = max(taller, a)
    if taller > a:
      step += taller - a
  print(step)

if __name__=='__main__':
  main()



Measured memory_bytes: 32260
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int num;
	while( (num = sc.nextInt()) != 0 ){
		int aCnt = 0;
		int bCnt = 0;
		for(int cnt = 0;cnt < num;cnt++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if( a < b ){
				bCnt += a + b;
			}else if( a > b ){
				aCnt += a + b;
			}else{
				aCnt += a;
				bCnt += b;
			}
		}
		System.out.printf("%d %d\n",aCnt,bCnt);
	}
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<double,double> dd;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<ii> > vvip;
typedef vector<ii> vii;
typedef map<int,int> mpi;
#define pb push_back
#define F first
#define S second
//#define MOD 1000000007
#define NA -1
#define ALL(v) v.begin(),v.end()
#define mp make_pair
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout<<#a<<" :";FOR(i123,x,y)cout<<setw(4)<<(a)[i123];cout<<endl;}
#define foreach(e, x) for (__typeof(x.begin()) e = x.begin(); e != x.end(); e++) 
#define clr(x) memset(x,0,sizeof(x));
#define sz(x) int((x).size())
#define endl '\n'
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
#define sc(t) scanf("%d",&t)
// vector<string> split(const string &s, char delim) {
//     stringstream ss(s);
//     string item;
//     vector<string> tokens;
//     while (getline(ss, item, delim)) {
//         tokens.push_back(item);
//     }
//     return tokens;
// }
typedef pair<pll,ll> ppll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
#define re return
#define MAX 100
ll cache[MAX+1][MAX+1];

ll ncr(int n,ll r)
{
	if(cache[n][r]==-1)
	cache[n][r] = ncr(n-1,r)+ncr(n-1,r-1);
	return cache[n][r];
}
ll get_ncr(ll n,ll r)
{
	ll i,j;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			cache[i][j]=-1;
		}
	}

	for(i=1;i<=n;i++)  //  initialize the cache
	{
		cache[i][0]=1;
		cache[i][i]=1;
	}
	return ncr(n,r);
}

int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	//     freopen("output.txt","w",stdout);;
	// #endif
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	
	ll n,a,b;
	cin>>n>>a>>b;
	vll v(n);
		map<int,int> mm;
	rep(i,n)
	{
		cin>>v[i];
		mm[v[i]]++;
	}

	sort(ALL(v));
	ll ac=a,nc=n-1;
	int ct=0;
	double sum=0;
	map<int,int> mc;
	while(ac-->0)
	{
		mc[v[nc]]=1;
		sum+=v[nc];
		nc--;
		ct++;
	}
	cout<<fixed<<sum/ct*1.0<<endl;	
	if( mc.size()==1)
	{
		ll ans=0;
		int nn =mm[v[n-1]];
		for(int i=a;i<=b;i++)
		{
			ans+=get_ncr(nn,i);
		}
		cout<<ans<<endl;
	}
	else
	{
		ll ans=1LL;
		map<int,int> op;
		for(int i=n-1;i>=n-1-a+1;i--)
			op[v[i]]++;
		map<int,int> done;
		foreach(e,op)
		{
			if(done[e->F]==0){
			ans*=(ll)get_ncr(mm[e->F],e->S);
			done[e->F]=1;
			}
		}
		cout<<ans<<endl;
	}
	
}


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

int main() {
  int N;
  cin>>N;
  vector<int> p={1};
  int a=6,b=9;
  while(a<100000){
    p.push_back(a);
    a*=6;
  }
  while(b<100000){
    p.push_back(b);
    b*=9;
  }
  sort(p.begin(), p.end());
  vector<int> z(N+1,100000);
  z.at(0)=0;
  for(int i=1;i<=N;i++){
    int j=0;
    while(i-p.at(j)>=0){
      z.at(i)=min(z.at(i),z.at(i-p.at(j))+1);
      if(j!=p.size()-1){
        j++;
      }
      else{
        break;
      }
    }
  }
  cout<<z.at(N)<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    bool ok = false;
    for (int i = 0; i < (int)s.size()-1; i++) {
        if (s.substr(i,2) == "AC") ok = true;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3580
import std.stdio;

void main() {
    size_t n, m;
    readf("%d %d\n", &n, &m);
    // 裏表は近傍の数に寄って決まる．偶数→裏, 奇数→表
    if (n == 1 && m == 1) {
        writeln(1);
    } else if (n == 1 || m == 1) { // 端:1, 他:2
        writeln(n * m - 2);
    } else { // 角:3, 端辺:5, 他:8
        writeln(n * m - (n - 1 + m - 1) * 2);
    }
}


Measured memory_bytes: 256
class UnionFind():
    n=1
    par=[0]
    rnk=[0]
    def __init__(self,size):
        self.n=size
        self.par=[i for i in range(self.n)]
        self.rnk=[0 for i in range(self.n)]
    def find(self,vertex1):
        if self.par[vertex1]==vertex1:
            return vertex1
        else:
            self.par[vertex1]=self.find(self.par[vertex1])
            return self.par[vertex1]
    def unite(self,vertex1,vertex2):
        vertex1=self.find(vertex1)
        vertex2=self.find(vertex2)
        if vertex1==vertex2:
            return
        if (self.rnk[vertex1]<self.rnk[vertex2]):
            self.par[vertex1]=vertex2
        else:
            self.par[vertex2]=vertex1
            if(self.rnk[vertex1]==self.rnk[vertex2]):
                self.rnk[vertex1]+=1
    def same(self,vetrex1,vertex2):
        return self.find(vetrex1)==self.find(vertex2)
H,W=map(int,input().split())
S=[list(input()) for i in range(H)]
G=UnionFind(H*W)
#i*W+j
for i in range(H):
    for j in range(W-1):
        if S[i][j]!=S[i][j+1]:
            G.unite(i*W+j,i*W+(j+1))
for i in range(H-1):
    for j in range(W):
        if S[i][j]!=S[i+1][j]:
            G.unite(i*W+j,(i+1)*W+j)
D=dict()
for i in range(H):
    for j in range(W):
        k=G.find(i*W+j)
        if not k in D:
            D[k]=[0,0]
        if S[i][j]=="#":
            D[k][0]+=1
        else:
            D[k][1]+=1
ans=0
for k in D:
    x=D[k][0]
    y=D[k][1]
    ans+=x*y
print(ans)


Measured memory_bytes: 73352
N, M = map(int, input().split())
X = [[] for i in range(N + 1)]
for i in range(M):
  a, b = map(int, input().split())
  X[a] += [b]
  X[b] += [a]
ans = [0] * (N + 1)
ans[1] = 1
from collections import deque
que = deque([1])
while que:
  q = que.popleft()
  for i in X[q]:
    if ans[i] == 0:
      ans[i] = q
      que.append(i)
print('Yes')
print(*ans[2:], sep='\n')


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

int main(){
  int n,b;
  long long sum=0;
  cin>>n;
  vector<int> a;
  for(int i=0;i<n;i++){
    int in;
    cin>>in;
    a.push_back(in-i-1);
  }
  sort(a.begin(),a.end());
  if(n%2!=0){
    b=a.at((n-1)/2);
  }else{
    b=(a.at(n/2-1)+a.at(n/2))/2;
  }
  for(int i=0;i<n;i++){
    sum+=abs(a.at(i)-b);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1400
import sys
import math
import itertools
import numpy

rl = sys.stdin.readline
a, b, h, m = map(int, rl().split())
theta = (h*60 + m) * 0.5
theta1 = m * 6
theta = abs(theta-theta1)
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(theta))
c = c**0.5
print(c)


Measured memory_bytes: 27200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m;
    vector<int> adj[100100];
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
    }
    cin >> s >> t;
    s--, t--;

    vvl dist(100100, vl(3, 1e18));
    dist[s][0] = 0;
    queue<pll> q;
    q.emplace(s, 0);
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int node = p.first;
        int kind = p.second;
        if (node == t && kind == 0) {
            cout << int(dist[t][0] / 3) << endl;
            return 0;
        }
        for (int to : adj[node]) {
            int next_kind = (kind + 1) % 3;
            if (dist[to][next_kind] == 1e18) {
                dist[to][next_kind] = dist[node][kind] + 1;
                q.emplace(to, next_kind);
            }
        }
    }
    puts("-1");
}


Measured memory_bytes: 14268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int sum=0;
  int ma;
  for(int i=0;i<n;i++){
    int s;
    cin>>s;
    sum+=s;
    ma=max(ma,s);
  }
  cout<<sum-ma/2;
}

Measured memory_bytes: 256
fun main (args : Array<String>) {
	val n = readLine()!!
	val s = readLine()!!
	val list : MutableList<String> = mutableListOf()
	for (i in s) {
		list.add(i.toString())
	}
	if ((n.toInt() % 2) == 1) {
		return println("No")
	}
	if (n.toInt() == 2) {
		if (list[0] != list[1]) {
			return println("No")
		}
	}
	for (i in 0..(n.toInt() / 2) - 1) {
		if (list[i] == list[i + (n.toInt() / 2)]) {
			continue
		} else {
			return println("No")
		}
	}
	println("Yes")
}

Measured memory_bytes: 33608
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


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

  
        string s;
        cin >> s;
        if(s=="MON") cout << 6;
        else if(s=="TUE") cout << 5;
        else if(s=="WED") cout << 4;
        else if(s=="THU") cout << 3;
        else if(s=="FRI") cout << 2;
        else if(s=="SAT") cout << 1;
        else if(s=="SUN") cout << 7;
              
        
        

}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    int N, M;
    while (cin >> N >> M, N)
    {
        vector<int> p(N);
        REP(i, N) { cin >> p[i]; }

        sort(RALL(p));

        int ans = 0;

        for (int i = 0; i < N;)
        {
            int sum = 0, cnt = 0;

            while (i < N && cnt < M)
            {
                sum += p[i++];
                cnt++;
            }

            if (cnt == M)
            {
                sum -= p[i - 1];
            }

            ans += sum;
        }

        Cout(ans);
    }

    return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, ans;

int main() {
	cin >> n;
	if(n & 1) ans = (n / 2) * (n - n / 2);
	else ans = (n / 2) * (n / 2);
	cout << ans << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
 
using namespace std ;
 
typedef tree<pair<pll,lli>,null_type,less<pair<pll,lli>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define MAXN 200000

int main()
{
    
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////  
  
	lli n;
	cin>>n;

	pair<string,lli> p[n];

	loopl(i,0,n)
	{
		cin>>p[i].ff>>p[i].ss;
	}
	string x;
	cin>>x;
	lli flag=0,sum=0;
	loopl(i,0,n)
	{
		if(flag == 0)
		{
			if(p[i].ff!=x) continue;
			else flag=1;
		}

		else sum+=p[i].ss;
	}
	cout<<sum;

}

        
 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;


int main(void){
    int n,k,s;
    cin>>n>>k>>s;
    vector<int>ans(n);
    if(s>n-k){
        for(int i=0;i<n;i++){
            if(k>0){
                ans[i]=s;
                k--;
            }
            else ans[i]=1;
        }
    }
    else{
        for(int i=0;i<n;i++){
            if(k>0){
                ans[i]=s;
                k--;
            }
            else ans[i]=1000000000;
        }
    }
    for(int i=0;i<n;i++){
        if(i==n-1)cout<<ans[i]<<endl;
        else cout<<ans[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <unordered_map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define flood(arr, c, s) for (int i=0; i<s; i++) arr[i] = c
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 1e5 + 2;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    int n;
    cin >> n;
    int h[n + 1];
    unordered_map<int, int> c;
    int f = 0;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
        f += c[i - h[i]];
        c[i + h[i]]++;
    }
    cout << f;
    return 0;
}

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

const int N = 19;

typedef long long ll;

int n,m;

ll ans = 0;

bool b[N] = {};
vector<int> adj[N];

void dfs (int u,int cnt){
  if(cnt == n){
    ans++;
    return;
  }

  b[u] = true;
  for(int v: adj[u]){
    if(!b[v]){
      dfs(v,cnt+1);
    }
  }
  b[u] = false;
}

int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  dfs(1,1);

  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a, b;
	cin >> a >> b;
	
	if(a==b)
		cout << "Draw";
	else
	{
		if(a>b && b!=1)
			cout << "Alice";
		else if(a>b && b==1)
			cout << "Bob";
		else if(a<b && a!=1)
			cout << "Bob";
		else if(a<b && a==1)
			cout << "Alice";
	}
		

	return 0;
}


Measured memory_bytes: 3596
#!/usr/bin/env python3
import numpy as np
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def blute(N, XY):
    ret = np.zeros(N, np.int64)
    for i in range(N):
        ret[i] = np.max(np.abs(XY - XY[i]).sum(axis=1))
    return np.max(ret)


def solve(N, XY):
    S = XY.sum(axis=1)
    p1 = np.argmax(S)
    p2 = np.argmin(S)
    D = XY[:, 0] - XY[:, 1]
    p3 = np.argmax(D)
    p4 = np.argmin(D)
    return max(S[p1] - S[p2], D[p3] - D[p4])
    # return blute(4, XY[[p1, p2, p3, p4]])


def main():
    # parse input
    N = int(input())
    XY = np.int64(read().split())
    XY = XY.reshape((N, 2))
    print(solve(N, XY))


# tests
T1 = """
3
1 1
2 4
3 2
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
4
"""

T2 = """
2
1 1
1 1
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
0
"""

TEST_T3 = """
>>> N = 100
>>> np.random.seed(1)
>>> solve(N, np.random.randint(1, 100, (N, 2)))
189
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 53068
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

vector<string> s;
void Enu(string T,int n)
{
	for (int i = n + 1; i < T.size(); i++) {
		string tmp = T;
		tmp.insert(tmp.begin() + i, '+');
		s.push_back(tmp);
		Enu(tmp, i + 1);
	}
}
int main()
{
	string S; cin >> S;
	s.push_back(S);
	Enu(S, 0);
	ll num = 0, ans = 0;
	for (int i = 0; i < s.size(); i++) {
		num = 0;
		for (int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == '+') {
				ans += num;
				num = 0;
			}
			else {
				num *= 10;
				num += (ll)(s[i][j] - '0');
			}
		}
		ans += num;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		long A =  Long.parseLong(W.split(" ")[0]);
		long B =  Long.parseLong(W.split(" ")[1]);
		long C =  Long.parseLong(W.split(" ")[2]);
		long D =  Long.parseLong(W.split(" ")[3]);

		A = A-1;
		long N = B - A ;

		long lcm = lcm(C,D);

		long AmodC = A /C;
		long AmodD = A /D;
		long AmodLCM = A/(lcm);

		long BmodC = B /C;
		long BmodD = B /D;
		long BmodLCM = B/(lcm);

		long ans = N - BmodC - BmodD + BmodLCM + (AmodC + AmodD - AmodLCM);


		System.out.println(ans);
	}


	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int main (){

  while(1){
    vector<int> point;
    int n,i,temp,sum;
    cin >> n;
    if (n==0)break;
    
    for(i=0;i<n;i++){
      cin >> temp;
      point.push_back(temp);
    }
    
    sort(point.begin(),point.end());
    
    sum = 0;
    
    for(i=1;i<n-1;i++){
      sum += point[i];
    }
    
    sum = sum / (n-2);
    
    cout << sum <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1220
def main():
    N = int(input())
    V = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]

    sum = 0
    for i in range(0, len(V)):
        tmp = V[i] - C[i]
        if (tmp >= 0):
            sum += tmp

    print(sum)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200200];
  int maxx1 = 0;
  int maxx2 = 0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    maxx1 = max(maxx1, a[i]);
  }
  int cnt = 0;
  for(int i=0; i<n; i++){
    if(a[i] == maxx1) cnt++;
    else maxx2 = max(maxx2, a[i]);
    if(cnt>=2) maxx2 = maxx1;
  }
  for(int i=0; i<n; i++){
    if(a[i] == maxx1)  cout << maxx2 << endl;
    else cout << maxx1 << endl;
  }
}

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
         ll n,m;
    cin>>n>>m;
    multiset<ll> s;
    multiset <ll > :: iterator itr;
    for(ll i=0;i<n;i++) {
        ll x;
        cin>>x;
        s.insert(x);
    }
    for(ll i=0;i<m;i++){
        itr = s.end();
        //cout<<*itr<<endl;
        itr--;
        ll ff = *itr;
        s.erase(itr);
        s.insert(ff/2);
    }
    ll ans = 0;
    for(itr=s.begin();itr!=s.end();itr++){
        ans += *itr;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
N=int(input())
L=list(map(int,input().split()))
count=0
for ii in range(N):
    for jj in range(ii+1,N):
        for kk in range(jj+1,N):
            if L[ii]!=L[jj] and L[jj]!=L[kk] and L[kk]!=L[ii] and L[ii]+L[jj]>L[kk] and L[jj]+L[kk]>L[ii] and L[kk]+L[ii]>L[jj]:
                count+=1
print(count)


Measured memory_bytes: 9192