akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
ll n,w[10000];

int main(){
	while(cin>>n){
		if(!n)return 0;
		for(int i=0;i<n;i++)cin>>w[i];
		sort(w,w+n);
		ll ans=0;
		for(int i=0;i<n;i++)ans+=w[i]*(n-1-i);
		cout<<ans<<endl;
	}
}

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

int main() {
	cout << fixed << setprecision(15);
	double n;
	cin >> n;
	vector<vector<int>>xy(n, vector<int>(2));
	for (int i = 0; i < n; i++)cin >> xy.at(i).at(0) >> xy.at(i).at(1);
	double ans = 0;
	//順列のやつ
	vector<int>a(n);
	for (int i = 0; i < n; i++)a.at(i) = i;
	sort(a.begin(), a.end());
	double dow = 0;
	do {
		dow++;
		double res = 0;
		for (int i = 0; i < n - 1; i++) {
			double ro = pow(xy.at(a.at(i)).at(0) - xy.at(a.at(i + 1)).at(0), 2) + pow(xy.at(a.at(i)).at(1) - xy.at(a.at(i + 1)).at(1), 2);
			ro = sqrt(ro);
			res += ro;
		}
		ans += res;
	} while (next_permutation(a.begin(), a.end()));
	ans = ans / dow;
	cout << ans << endl;
}

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

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  int n, m, c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0; i<m; i++) {
    cin>>b[i];
  }
  int cnt=0;
  for(int i=0; i<n; i++) {
    int sum=0;
    for(int j=0; j<m; j++) {
      int a;
      cin>>a;
      sum+=a*b[j];
    }
    if(sum+c>0)
      cnt++;
  }
  std::cout << cnt << std::endl;
  
  return 0;
}



Measured memory_bytes: 256
n, a, b = map(int, raw_input().split())
s = raw_input()
c = a + b

for e in s:
    if e == "c":
        print "No"
    elif e == "b":
        if b > 0 and c > 0:
            print "Yes"
            b -= 1
            c -= 1
        else:
            print "No"
    else:
        if c > 0:
            print "Yes"
            c -= 1
        else:
            print "No"


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define F first
#define S second
using namespace std;

typedef pair< int,int > point;
vector< point > graph[10001];
vector< int > v(10001);
int n;
const int INF=1<<30;

void dijkstra(int s){
    priority_queue< point,vector< point >,greater< point > >pq;
    pq.push({0,s});
    fill(v.begin(),v.end(),INF);
    v[s]=0;
    while(!pq.empty()){
        point p=pq.top();
        pq.pop();
        REP(i,graph[p.S].size()){
            int nex=graph[p.S][i].S;
            int cost=p.F+graph[p.S][i].F;
            if(v[nex]>cost){
                v[nex]=cost;
                pq.push({cost,nex});
            }
        }
    }
}

int main(){
    scanf("%d",&n);
    int u,k,to,c;
    REP(i,n){
        scanf("%d%d",&u,&k);
        REP(j,k){
            scanf("%d%d",&to,&c);
            graph[u].push_back({c,to});
        }
    }
    dijkstra(0);
    REP(i,n){
        printf("%d ",i);
        printf("%d\n",v[i]);
    }
    return 0;
}




Measured memory_bytes: 8092
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#define int long long

using namespace std;

int a, b, c, d;

int f(int x, int y) {
  return x / y;
}

int gcd(int a, int b) {
  return (b ? gcd(b, a % b) : a);
}

int lcm(int a, int b) {
  return a / gcd(a, b) * b;
}

int32_t main() {
  int n;
  cin >> n;
  vector < pair <int, int> > vec;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    vec.push_back({y, x});
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  bool ok = 1;
  for (int i = 0; i < vec.size(); i++) {
    ans += vec[i].second;
    ok &= ans <= vec[i].first;
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 6384
/*
~Like a small boat
~On the ocean
~Sending big waves
~Into motion
!Like how a single word
!Can make a heart open
!I might only have one match
!But I can make an explosion
#And all those things I didn't say
#Wrecking balls inside my brain
#I will scream them loud tonight
#Can you hear my voice this time?
@This is my fight song
@Take back my life song
@Prove I'm alright song
@My power's turned on
$Starting right now I'll be strong
$I'll play my fight song
$And I don't really care if nobody else believes
$'Cause I've still got a lot of fight left in me!!!
*/

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

#define  F  first
#define  S  second
#define  pb push_back
#define  mp make_pair
#define  sz(s) (int)s.size()
typedef long long int ll;
const int N = 3e3+5;

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

    ll n;cin>>n;
    for(int i=0;i<=n;i++)
    {
        ll a = i*4;
        if(a>n)continue;
        if( (n-a)%7==0 )cout<< "Yes\n",exit(0);
    }
    cout<< "No\n";



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  ll a[n], dp[n][n], sum[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    if(i) sum[i] = sum[i - 1] + a[i];
    else sum[i] = a[i];
  }
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) dp[i][j] = 1e18;
  for(i = 0; i < n; ++i) dp[i][0] = 0;
  for(i = 1; i < n; ++i) for(j = 0; j < n - i; ++j) {
    for(k = 0; k < i; ++k) if(dp[j][i] > dp[j][k] + dp[j + k + 1][i - k - 1] + sum[j + i] - (j ? sum[j - 1] : 0)) {
      dp[j][i] = dp[j][k] + dp[j + k + 1][i - k - 1] + sum[j + i] - (j ? sum[j - 1] : 0);
    }
  }
  printf("%lld", dp[0][n - 1]);
  return 0;
}

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

int a[222222];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int l = 0, r = 1e9;
    while(l + 1 < r) {
        auto m = (l + r) / 2;
        long x = 0;
        for(int j = 0; j < n; j++)
            x += (a[j] - 1) / m;
        (x > k ? l : r) = m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4372
<?php
	$s=fgets(STDIN);
	$a=floor(strlen($s)/2)-1;
	for(;;){
		$f=1;
		for($i=0;$i<$a;$i++)$f&=$s[$i]==$s[$i+$a];
		if($f){
			echo $a*2;
			exit;
		}
		$a--;
	}


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

int main() {
   long long n,ans = 1;
  cin >> n;
  for(int i = 1;i <= n;i++){
    ans = (ans*i)%(1000000000+7);
  }
  cout << ans%(1000000000+7) << endl;
}


Measured memory_bytes: 256
/*
ID: taoxiaa1
PROG: concom
LANG: C++
*/
//URAL ID:248353QC
#include<bits/stdc++.h>
using namespace std;
//FILE *fin, *out;
//fin = fopen("money.fin", "r");
//out = fopen("money.out", "w");
//ofstream fout("money.out");
//ifstream fin("money.in");
long long dp1[100005], dp2[100005], t[100005], s[100005];
int main() {
    int n;
    long long c;
    scanf("%d%lld", &n, &c);
    for(int i = 1; i <= n; i++)
        scanf("%lld%lld", &s[i], &t[i]);
    s[0] = 0, t[0] = 0;
    for(int i = 1; i <= n; i++)
        dp1[i] = dp1[i - 1] + t[i];
    for(int i = n; i >= 1; i--) {
        if(i == n)
            dp2[i] = dp2[0] + t[i];
        else
            dp2[i] = dp2[i + 1] + t[i];
    }
    long long sum = 0,temp=0;
    for(int i = 1; i <= n; i++)
    {
        sum=max(sum,dp1[i]-s[i]);
        sum=max(dp2[i]-c+s[i]+temp,sum);
        temp=max(temp,dp1[i]-2*s[i]);
    }
    temp=0;
    for(int i=n;i>=1;i--){
        sum=max(sum,dp2[i]-c+s[i]);
        sum=max(sum,dp1[i]-s[i]+temp);
        temp=max(dp2[i]-2*c+2*s[i],temp);
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a, b, x;
  double theta;
  cin >> a >> b >> x;
  if( a * a * b / 2 <= x){
    theta = atan(2 * (a * a * b - x) / a / a / a);
  }
  else {
    theta = atan(a * b * b / 2 / x);
  }
  double PI = 3.14159265358979323846264338327950288419716939937510;
  theta = theta * 180 / PI;
  printf("%.10f\n", theta);
}

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

Measured memory_bytes: 256
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<long long> comb = vector<long long>(100 * 100,-1);

long long combination(long long n, long long r) {
	if (n == 1 || n == 0)return 1;
	if (n == r)	return 1;
	else if (r == 0)return 1;
	else if (r == 1)return n;
	else if (comb[100 * (n - 1) + (r - 1)] != -1) return comb[100 * (n - 1) + (r - 1)];
	else {
		auto res = combination(n - 1, r - 1) + combination(n - 1, r);
		comb[100 * (n - 1) + (r - 1)] = res;
		return res;
	}
}


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (2 * b == a + c) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int a[100000];

int main()
{
	int n,k;
	int ans=1e9-1;
	int mindex;
	
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==1)
			mindex=i;
	}
	//最初に埋める
	for(int i=max(mindex-k+1,0);i<mindex+1;i++)
	{
		//copy(a,a+n,b);
		int cnt=1;
		int l=i;
		if(l>0)
			cnt+=l/(k-1)+(l%(k-1)==0 ? 0: 1);
		//cerr<<i<<" "<<cnt;
		int r=i+k-1;
		if(r<n)
			cnt+=(n-r-1)/(k-1)+((n-r-1)%(k-1)==0 ? 0 : 1);
		ans=min(cnt,ans);
		//cerr<<" "<<cnt<<endl;
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        
        String[] splitS = S.split("", 0);
        String[] splitT = T.split("", 0);
        
        int match = 0;
        
        for(int i = 0; i < splitS.length; i++){
            if(splitS[i].equals(splitT[i])){
                match++;
            }
        }
        
        System.out.println(match);
    }
}

Measured memory_bytes: 23124
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	sum := make([]int, len(s)+1)
	sum[0] = 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'B' {
			sum[i+1] = sum[i] + 1
		} else {
			sum[i+1] = sum[i]
		}
	}
	ans := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'W' {
			ans += sum[i] - sum[0]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3584
a, b = map(int, input().split())
while a > 0:
    a, b = b % a, a
ret = 1
d = 2
while b >= d * d:
    if b % d == 0:
        ret += 1
        while b % d == 0:
            b //= d
    d += 1
if b > 1:
    ret += 1
print(ret)



Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MAX 100100
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,E,T,x[MAX];
ll ans,f[MAX],mn=1e18;
int main()
{
	n=read();E=read();T=read();
	for(int i=1;i<=n;++i)x[i]=read();
	memset(f,63,sizeof(f));f[0]=0;
	for(int i=1,j=0;i<=n;++i)
	{
		for(;T<=(x[i]-x[j+1])<<1;++j)mn=min(mn,f[j]-2*x[j+1]);
		if(j<i)f[i]=min(f[i],f[j]+T);
		f[i]=min(f[i],mn+2*x[i]);
	}
	cout<<f[n]+E<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>

int main() {
	int n, k, ans = 1000000000, h[100000];
	std::cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		std::cin >> h[i];
	}
	std::sort(h, h + n);
	for (int i = 0; i < n - k + 1; ++i) {
		if (ans >= h[i + k - 1] - h[i]) { ans = h[i + k - 1] - h[i]; }
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin >> s;
	int l,r;
	bool flag = false;
	for(int i = 0; i < s.size(); i++) {
		if (s[i] == s[i+1]){
			flag = true;
			l = i;
			r = i+ 1;
			break;
		}
		else if(s[i] == s[i + 2]){
			flag = true;
			l = i;
			r = i+2;
		}
	}
	if(flag){
		cout << l+1 << ' ' << r+1 << endl;
	}
	else{
		cout << -1 << ' ' << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 512
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line: Vec<i32> = read_as_vec();
    let (n, m, c) = (line[0], line[1], line[2]);

    let b: Vec<i32> = read_as_vec();
    let mut counter = 0;

    for _ in 0..n{
        let a: Vec<i32> = read_as_vec();
        let sum = a.iter().zip(b.iter()).map(|x| x.0*x.1).sum::<i32>();
        if sum > -c{
            counter += 1;
        }
    }
    println!("{}", counter);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main () 
{
  int x,y,z;
  while(1) {
  scanf("%d %d",&x,&y);
  if(x == 0 && y == 0)
    break;
  if (x > y ) {
    z = x;
    x = y;
    y = z;
   }
   printf("%d %d\n", x, y);
   }
  return 0;
}

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

int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int nedan = 0;
    if (A+B>C*2) {
        if (X<Y) {
            nedan = X * C * 2;
            if (B < C * 2) {
                nedan += (Y - X) * B;
            } else {
                nedan += (Y - X) * C * 2;
            }
        } else {
            nedan = Y * C * 2;
            if (A < C * 2) {
                nedan += (X - Y) * A;
            } else {
                nedan += (X - Y) * C * 2;
            }
        }
    } else {
        nedan = A*X + B*Y;
    }
    cout << nedan << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
//#include <unordered_set>
#define mkp make_pair
#define err cout<<"here"<<endl
using namespace std;
const double EPS=1e-12;
typedef long long lon;
typedef unsigned long long ull;
typedef set<int>::iterator IT;
const lon SZ=100010,SSZ=30,APB=52,mod=97,one=1;
const lon INF=0x7FFFFFFF;
lon n,m;
struct nd{
	lon to,wt;
	nd(lon a=0,lon b=0):to(a),wt(b){}
};

void init()
{
	cin>>n;
	int fm=n/100,lt=n%100;
	bool ok1=fm>=1&&fm<=12;
	bool ok2=lt>=1&&lt<=12;
	if(ok1&&ok2)
	{
		cout<<"AMBIGUOUS"<<endl;
	}
	else if(ok1)
	{
		cout<<"MMYY"<<endl;
	}
	else if(ok2)
	{
		cout<<"YYMM"<<endl;
	}
	else
	{
		cout<<"NA"<<endl;
	}
}


void work()
{
	
}

void release()
{
	
}

int main()
{
	std::ios::sync_with_stdio(0);
	//freopen("d:\\1.txt","r",stdin);
	int casenum;
	//cin>>casenum;
	//cout<<casenum<<endl;
	//for(int time=1;time<=casenum;++time)
	//for(int time=1;cin>>n>>m;++time)
	{
		//cout<<"Case #"<<time<<": ";
		init();
		work();
		release();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
const int MOD=1e9+7;
#define SZ 666666
int h,w;
char s[105][105];
int g[105][105];
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;++i)
		cin>>(s[i]+1);
	memset(g,127/3,sizeof g);
	g[1][1]=(s[1][1]=='#');
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
		{
			g[i][j+1]=min(g[i][j+1],g[i][j]+(s[i][j+1]=='#'&&s[i][j]!='#'));
			g[i+1][j]=min(g[i+1][j],g[i][j]+(s[i+1][j]=='#'&&s[i][j]!='#'));
		}
	cout<<g[h][w];
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int s;
			cin >> s;
			s--;
			a[s] |= 1 << i;
		}
	}

	int p = 0;
	for (int i = 0; i < m; ++i) {
		int x;
		cin >> x;
		p |= x << i;
	}
	int ans = 0;
	for (int s = 0; s < (1 << n); s++) {
		int t = 0;
		for (int i = 0; i < n; i++) {
			if (s >> i & 1) {
				t ^= a[i];
			}
		}
		if (t == p) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    s = input().rstrip()
    alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' #26
    
    res = []
    for i in s:
        res.append(alphabet[(alphabet.index(i)+n)%26])
    print(''.join(map(str, res)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  ll a,b;
  cin>>a>>b;
  if(a%b==0) co(-1);
  else co(a);
  
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll n, m, d; cin >> n >> m >> d;
  ll t = n - d;
  if(d != 0) t *= 2;
  cout << fixed << setprecision(7);
  cout << (long double) t * (m - 1) / n / n << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
n = len(S)

ans = 0
p = 1
c = pow(2, n - 1)

for i in range(n):
    for j in range(i, n):
        if j == i:
            ans += p * c * int(S[-j - 1])
            c //= 2
        else:
            ans += p * c * int(S[-j - 1])
    p *= 10

print(ans)

Measured memory_bytes: 9120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
map<int ,int >vis;
int main()
{
    int n,x;
    int maxx=-1;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        vis[x]++;
        vis[x-1]++;
        vis[x+1]++;
        maxx=max(maxx,max(vis[x],max(vis[x-1],vis[x+1])));
    }
    printf("%d\n",maxx);
    return 0;
}


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

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

int n;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> n;
    int maxi = 0;
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        maxi = max(maxi,x);
        ans += maxi-x;
    }
    cout << ans << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  if(S=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int M;
	cin >> M;
	int x = 24 - M + 24;
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3680
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
	ll N;
	cin >> N;
	ll ans = (ll)sqrt(N);
	cout << ans*ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> x(n);
    repeat(i, n) cin >> x[i];
    
    auto pos = [&h, &w](int t) -> pair<int, int> {
        int x = t / w;
        int y;
        if (x % 2 == 0) {
            y = t % w;
        }
        else {
            y = (w - 1) - (t % w);
        }
        return {x, y};
    };
    
    vector<vector<int>> color(h, vector<int>(w, 0));
    
    int c = 0;
    repeat(i, n) {
        rep(x[i]) {
            pair<int, int> p = pos(c);
            color[p.first][p.second] = i + 1;
            ++c;
        }
    }
    
    repeat(i, h) {
        repeat(j, w) {
            cout << color[i][j] << " ";
        }
        cout << endl;
    }
    
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9 + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, p;
  cin >> a >> p;
  int chip = a * 3 + p;
  cout << chip / 2 << "\n";
  return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e18;

#define MAX_V 100010
vector<ll> d1, d2;
ll V;
struct edge {
	ll to, cost;
};
vector<edge> G1[MAX_V], G2[MAX_V];
// O(ElogV)
vector<ll> dijkstra(ll s, vector<edge> G[]) {
  vector<ll> d(V);
  rep(i, 0, V) d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(make_pair(0, s)); // distance, index)

	while(!q.empty()) {
		P p = q.top();
		q.pop();
		ll v = p.second;
		if(d[v] < p.first) continue;
		rep(i, 0, G[v].size()) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
  return d;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  ll m, s, t;
  cin >> V >> m >> s >> t;
  rep(i, 0, m) {
    ll u, v, a , b;
    cin >> u >> v >> a >> b;
    u--; v--;
    edge e;
    e.to = v;
    e.cost = a;
    G1[u].push_back(e);
    e.to = u;
    G1[v].push_back(e);
    e.to = v;
    e.cost = b;
    G2[u].push_back(e);
    e.to = u;
    G2[v].push_back(e);
  }
  d1 = dijkstra(--s, G1);
  d2 = dijkstra(--t, G2);

  ll max_v = 0;
  vector<ll> rsl;
  for(int i = V - 1; i >= 0; --i) {
    ll tmp = 1e15 - (d1[i] + d2[i]);
    max_v = max(max_v, tmp);
    rsl.push_back(max_v);
  }
  rep(i, 0, V) {
    cout << rsl[V - i - 1] << endl;
  }
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w;
string s[100];

int main() {
	cin >> h >> w;
	inc(i, h) { cin >> s[i]; }
	
	inc(i, w + 2) { cout << "#"; } cout << "\n";
	inc(i, h) { cout << "#" << s[i] << "#" << "\n"; }
	inc(i, w + 2) { cout << "#"; } cout << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}
main(){
  int a,b,g,h,r=1;
  cin>>a>>b;
  g=h=gcd(a,b);
  for(int i=2;i*i<=h;++i){
    if(g%i==0){
      r++;
      while(g%i==0)g/=i;
    }
  }
  if(g>1)r++;
  cout<<r;
}

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

int main(){
  string N;
  cin >> N;
  int ans = 100000;
  int num = 0;
  
  for(int i=0; i<N.size()-2; i++){
    string S;
    S += N.at(i);
    S += N.at(i+1);
    S += N.at(i+2);
    num = atoi(S.c_str());
    ans = min(ans, abs(753 - num));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
SP = [None] * N
for i in range(N):
    s, p = input().split()
    SP[i] = (s, int(p))

cities = {sp[0] for sp in SP}
cities = sorted(list(cities))
points = sorted([sp[1] for sp in SP], reverse=True)

for c in cities:
    for p in points:
        tpl = (c, p)
        if tpl in SP:
            print(SP.index(tpl) + 1)


Measured memory_bytes: 3064
//
//  main.cpp
//  GCJ
//
//  Created by shitian.ni on 2018/06/19.
//  Copyright © 2018 shitian.ni. All rights reserved.
//

#include <iostream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin>>N;
    vector<int>vec(N);
    unordered_map<int,int> ma;
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>vec[i];
        ma[vec[i]]+=1;
        if(ma[vec[i]]>vec[i])ans++;
    }
    for(int i=0;i<N;i++){
        if(ma[vec[i]]<vec[i])ans++;
    }
    cout<<ans<<endl;
   
    
    
    return 0;
}


Measured memory_bytes: 4644
# https://atcoder.jp/contests/abc129/tasks/abc129_c
# 典型的なDP

MOD = 10**9 + 7
import numpy as np
# dp[i]をi段目までの通りの数とする。
N, M = list(map(int, input().split()))
to_zero = np.full((N + 1), False).tolist()
for _ in range(M):
    to_zero[int(input())] = True  # 床が抜けているところ

# dpテーブルの用意
dp = np.full((N + 1), -1).tolist()
dp[0] = 1
dp[1] = 0 if to_zero[1] else 1
for i in range(2, N + 1):
    dp[i] = 0 if to_zero[i] else dp[i - 2] + dp[i - 1]
    if dp[i] > MOD:
        dp[i] %= MOD

print(dp[-1])


Measured memory_bytes: 19904
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> ma;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> s;
  if (s[s.size() - 1] == 's')
  {
    out(s + "es");
  }
  else
  {
    out(s + 's');
  }
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}

Measured memory_bytes: 3652
import collections
import itertools
import sys

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s=input()
k=len(s)
n=int(s)

m = 2
p = 1
res = []
while True:
    modulo = (n % m + m) % m
    n -= p if modulo else 0
    res.append(1 if modulo else 0)
    m *= 2
    p *= -2
    if not n:
        break

for d in reversed(res):
    print(d, end="")
print("")


Measured memory_bytes: 3316
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1e16; //10^9+7


int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    REP(i, a + 1)REP(j, b + 1)REP(k, c + 1){
        if(i * 500 + j * 100 + k * 50 == x){
            ans++;
        }
    }
    print(ans);
}

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


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()(int n) {
		vi c(n+1, 1);

		ll ans=1;
		for(ll i=2;i<=n;i++)
		{
			if(c[i]==1)
			{
				int ki=1;
				for(ll k=i;k<=n;k*=i,ki++)
				{
					for(ll j=k;j<=n;j+=k)
					{
						c[j]=c[j]/ki*(ki+1);
					}
				}
			}
			ans+=i*c[i];
		}
		return ans;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		cout << solve()(n) << "\n";
	}
	return 0;
}


Measured memory_bytes: 42244
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 55;
const int M = (1 << 20);
int n;
vi adj[N];
int em[N];
ll f[N][M]; 
map<ii, int> edgeID;

void markEdges (int u, int v, int id) {
	vi p(n, -1), d(n, -1);
	d[u] = 0;
	queue<int> Q;
	Q.push(u);
	while (!Q.empty()) {
		int x = Q.front(); Q.pop();
		if (x == v) break;
		Trav(y, adj[x]) if (d[y] == -1) {
			p[y] = x;
			d[y] = 1 + d[x];
			Q.push(y);
		}
	}
	int t = v;
	vi seq;
	while (t != -1) {
		seq.pb(t);
		t = p[t];
	}
	dbg(u, v, seq);
	Foz(i, sz(seq) - 1) {
		int k = edgeID[ii(seq[i], seq[i + 1])];
		em[k] |= (1 << id);
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int a, b, m;
	cin >> n;
	Foz(i, n - 1) {
		cin >> a >> b;
		a--; b--;
		edgeID[ii(a, b)] = i + 1;
		edgeID[ii(b, a)] = i + 1;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	cin >> m;
	Foz(i, m) {
		cin >> a >> b;
		a--; b--;
		markEdges(a, b, i);
	}
	
	memset(f, 0, sizeof f);
	f[0][0] = 1;
	For(i, 1, n) {
		dbg(em[i]);
		Foz(j, M) f[i][j] += f[i - 1][j];	
		Foz(j, M) f[i][(j | em[i])] += f[i - 1][j];
	}
	cout << f[n - 1][(1 << m) - 1] << '\n';
}



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

int main() 
{
    int H,W;
    cin >> H >> W;
    string S[51];
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    
    const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
    const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
    
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                continue;
            }
            
            int num = 0;
            for (int k = 0; k < 8; k++) {
                int sum1 = i + dy[k];
                int sum2 = j + dx[k];
                if (sum1 < 0 || H <= sum1) {
                    continue;
                }
                if (sum2 < 0 || W <= sum2) {
                    continue;
                }
                if (S[sum1][sum2] == '#') {
                    num++;
                }
            }
            S[i][j] = char(num + '0');
        }
    }
    
    for (int i = 0; i < H; i++) {
        cout << S[i] << endl;
    }
    
}

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

int main()
{
	list<int> v;
	int n,b;
	string s;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="insert"){
			scanf("%d",&b);
			v.push_front(b);
		}
		if(s=="delete"){
			scanf("%d",&b);
			for( list<int>::iterator it=v.begin();it!=v.end();it++){
				if(*it==b){
					v.erase(it);
					break;
				}
			}
		}
		if(s=="deleteFirst"){
			v.pop_front();
		}
		if(s=="deleteLast"){
			v.pop_back();
		}
	}
	
	for(list<int>::iterator it=v.begin();it!=v.end();it++){
		if(it!=v.begin()) printf(" "); 
		printf("%d",*it);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 34420
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 
 
ll csum(ll n) {
    return n * (n+1) / 2;
}
 
int main() {
    ll n; 
    cin >> n;
    ll ret = csum(n);
    ret -= csum(n/3)*3;
    ret -= csum(n/5)*5;
    ret += csum(n/15)*15;
    cout << ret << endl; 
    return 0;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string s;
    cin >> s;
    int r = 0;
    int b = 0;

    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            r++;
        }else{
            b++;
        }
    }

    cout << 2*min(r,b) << endl;
}

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

//------------------------------------------------------------
using ll = long long;
#define int ll

#define FOR(i, s, e) for (ll i = ll(s); i < (ll)e; ++i)
#define RFOR(i, s, e) for (ll i = ll(e) - 1; i >= ll(s); --i)
#define REP(i, n) for (ll i = 0, i##_size = n; i < i##_size; ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)

//------------------------------------------------------------
template <class T>
struct arr : public vector<T> {
	arr() {}
	arr(ll n, T v = T()) : vector<T>(n, v) {}

	void init(ll n, T v = T()) {
		this->clear();
		this->resize(n, v);
	}

	ll sz() const {
		return (ll)this->size();
	}
	void pb(T v) {
		this->push_back(v);
	}
};
using aint = arr<ll>;
using aaint = arr<arr<ll>>;

template <class T>
struct que : public queue<T> {
	ll sz() const {
		return (ll)this->size();
	}
	T popfront() {
		T v = this->front();
		this->pop();
		return v;
	}
};

//------------------------------------------------------------
struct input_s {
	template <class T>
	operator T() {
		T var;
		cin >> var;
		return var;
	}
};
input_s input() {
	return input_s();
}

struct input_ar {
	ll n;
	input_ar(ll n_) : n(n_) {}

	template <class T>
	operator arr<T>() {
		arr<T> var(n);
		REP(i, n) {
			cin >> var[i];
		};
		return var;
	}
};
input_ar input(ll n) {
	return input_ar(n);
}

template <class T>
void output(T var) {
	cout << (var) << '\n';
}

//------------------------------------------------------------
template <class T> void chmin(T& a, T b) { if (b < a) { a = b; } }
template <class T> void chmax(T& a, T b) { if (b > a) { a = b; } }

struct bfs {
	aint froms;
	aint steps;

	bfs(int N, aaint const& adjacency) {
		froms.init(N, -1);
		steps.init(N, -1);

		que<ll> queue;
		queue.push(0);
		froms[0] = 0;
		steps[0] = 0;

		while (queue.empty() == false) {
			ll p = queue.popfront();

			for (ll n : adjacency[p]) {
				if (froms[n] != -1) {
					continue;
				}

				froms[n] = p;
				steps[n] = steps[p] + 1;
				queue.push(n);
			}
		}
	}
};

//------------------------------------------------------------
void myMain();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(16);
	myMain();
	return 0;
}

//------------------------------------------------------------
void myMain() {
	int N = input();
	int M = input();

	aaint R(N);
	REP(i, M) {
		int a = input();
		int b = input();
		R[a - 1].pb(b - 1);
		R[b - 1].pb(a - 1);
	}

	bfs bfs(N, R);

	output("Yes");
	FOR(i, 1, N) {
		output(bfs.froms[i] + 1);
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  for(int i = 0; i < n-1; i++) cin >> c.at(i);
  int sum = 0;
  for(int i = 0; i < n; i++) sum += b.at(i);
  for(int i = 0; i+1 < n; i++) {
    if(a.at(i+1) - a.at(i) == 1) sum += c.at(a.at(i) - 1);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256