akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

	priority_queue<ll> que;
	rep(i,n)que.push(a[i]);

	while(m--){
		ll p = que.top();que.pop();
		p /= 2;
		que.push(p);
	}
	ll ans = 0;
	while(!que.empty()){
		ll p = que.top();que.pop();
		ans += p;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2168
s = list(input())
n = len(s)

s1 = [s[i] for i in range((n-1)//2)]
s2 = [s[i] for i in range((n+3)//2-1, n)]

sr = list(reversed(s))
s1r = list(reversed(s1))
s2r = list(reversed(s2))

if s == sr and s1 == s1r and s2 == s2r:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n = int(input())

nowa = 1
nowt = 1
for i in range(n):
    
    (t, a) = list(map(int, input().split()))
    bai = max((nowa * -1 // a) * -1, (nowt * -1 // t) * -1)
    nowa = a * bai
    nowt = t * bai

print(nowa + nowt)

Measured memory_bytes: 3060
n = int(input())
w = list(map(int, input().split()))

s1 = sum(w)
s2 = 0
ans = 100000
for i in range(n):
  s1 -= w[i]
  s2 += w[i]
  if ans > abs(s1-s2):
    ans = abs(s1-s2)

print(ans)

Measured memory_bytes: 38256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2,tune=native")

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

#define FORMAT setfill('0') << setw(6)

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    int P[M], Y[M];
    vector<int> foo[100000];
    for (int i = 0; i < M; i++) {
	cin >> P[i] >> Y[i];
	foo[P[i] - 1].push_back(Y[i]);
    }
    for (int i = 0; i < 100000; i++) if (!foo[i].empty()) sort(foo[i].begin(), foo[i].end());
    for (int i = 0; i < M; i++) {
	auto *bar = &foo[P[i] - 1];
	cout << FORMAT << P[i];
	cout << FORMAT << lower_bound(bar->begin(), bar->end(), Y[i]) - bar->begin() + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    auto calc = [&](ll x) {
        return ((A * x) / B) - A * (x / B);
    };
    cout << calc(min(B - 1, N)) << endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

vector<Int> G[2001];

int main() {
    Int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    for (Int i = 0; i < n - 1; i++) {
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    vector<Int> res(n, 0);
    for (Int i = 0; i < n; i++) {
        queue<Int> q;
        q.push(i);
        vector<Int> d(n, INF);
        d[i] = 0;
        while (not q.empty()) {
            Int p = q.front();
            q.pop();
            for (Int j = 0; j < (Int)G[p].size(); j++) {
                Int to = G[p][j];
                if (d[to] > d[p] + 1) {
                    d[to] = d[p] + 1;
                    q.push(to);
                }
            }
        }
        for (Int j = 0; j < n; j++) {
            if (d[j] == INF or d[j] == 0) continue;
            res[d[j]]++;
        }
    }
    for (Int i = 1; i <= n - 1; i++) {
        dump(res[i] / 2);
    }
    return 0;
}

Measured memory_bytes: 384
N, X = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)
(0..N-1).each do |i|
  x[i] = (X - x[i]).abs
end

def euclid (a, b)
  if(a < b)
    temp = a
    a = b
    b = temp
  end
  if(b < 1)
    return -1
  end
  
  if((a % b) == 0)
    return b;
  end
  return euclid(b, a%b)  
end

if(N != 1)
  answer = euclid(x[0], x[1])
else
  answer = x[0]
end

(2..N-1).each do |i|
  check = euclid(answer, x[i])
  if(answer > check)
    answer = check
  end
end
puts answer

Measured memory_bytes: 9484
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[410][410];

int go(int a,int b,vector<int> &v){
	if(a==b) return 0;
	if(dp[a][b]!=INF) return dp[a][b];
	int s=v[b]-v[a-1];
	For(i,a,b-1){
		dp[a][b]=min(dp[a][b],go(a,i,v)+go(i+1,b,v)+s);
	}
	return dp[a][b];
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	vector<int> v(n+1);
	v[0]=0;
	For(i,1,n){
		cin>>v[i]; v[i]+=v[i-1];
	}
	For(i,0,n) For(j,0,n) dp[i][j]=INF;
	cout<<go(1,n,v)<<"\n";
	return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T = sc.nextInt();
		long[]t = new long[N];
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
		}
		sc.close();
		long cnt = T;
		long k = T;
		for(int i = 1; i < N; i++) {
			if(t[i] < k) {
				cnt -= (k - t[i]);
				k = t[i] + T;
				cnt += T;
			}else if(t[i] == k){
				cnt += T;
				k += T;
			}else if(t[i] > k) {
				cnt += T;
				k = t[i] + T;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 93376
# https://atcoder.jp/contests/abc160/submissions/11310424

def main():
    from itertools import combinations

    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1

    def dist(a, b, X=X, Y=Y):
        return min(
            abs(a - b),
            abs(a - X) + abs(b - Y) + 1,
            abs(a - Y) + abs(b - X) + 1
        )

    ctr = [0] * N
    for combi in combinations(range(N), r=2):
        ctr[dist(*combi)] += 1

    it = iter(ctr)
    next(it)
    print(*it, sep='\n')


if __name__ == '__main__':
    main()


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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) {
        cin >> d.at(i);
    }
    int ans = 0;
    sort(d.begin(), d.end());
    rep(i, n) {
        if (i == 0 || d.at(i-1) != d.at(i)) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {	
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new AOJ0067();
	}
	
	class AOJ0067{
		boolean sw[][] = new boolean[12][12];
		
		void dfs(int x,int y){
			sw[y][x]=false;
			int[] sx={1,0,-1,0},sy = {0,1,0,-1};
			for(int i=0;i<4;i++){
				int nx = x+sx[i],ny=y+sy[i];
				if(nx<0||nx>=12||ny<0||ny>=12)continue;
				if(sw[ny][nx]==true)dfs(nx,ny);
			}
			return;
		}
		
		public AOJ0067() {
			Scanner in = new Scanner(System.in);
			while(in.hasNext()){
				for(int s=0;s<12;s++){
					String a = in.next();
					for(int i=0;i<12;i++)sw[s][i]=a.charAt(i)=='1'? true:false;
				}
				int cnt = 0;
				for(int s=0;s<12;s++)for(int i=0;i<12;i++)if(sw[s][i]==true){
					cnt++;
					dfs(i,s);
				}
				System.out.println(cnt);
			}
		}
	}
	
	
	
	
	
	
	
	
	
	class  AOJ0155{
		int d[];
		int n;
		int x[];
		int y[];
		int ban[];
		boolean sw;
		ArrayList<Integer> result;
		int back[];
		int[][] cost;
		void dijkstra(int s,int g){
			d = new int[n+1];d[s]=0;
			Arrays.fill(d,100000);
			boolean used[] = new boolean[n+1];
			int sumn[] = new int[n+1];
			int v=s;
			int save = -1;
			back = new int[n+1];
			while(true){
				save = v;
				v=-1;
				for(int u=1;u<n+1;u++)if(!used[u]&&(v==-1||(d[u]<d[v]))){
					v=u;
				}
				if(v==-1)break;
				else back[v]=save;
				used[v]=true;
				for(int u=1;u<n+1;u++)d[u]=Math.min(cost[u][v]+d[v],d[u]);
			}
			for(int i=1;i<d.length;i++){
				System.out.println(i+" "+d[i]);
			}
			int now=g;
			result = new ArrayList<Integer>();
			int a=0;
//			for(int i=0;i<back.length;i++){
//				System.out.println(i+" "+back[i]);
//			}
			while(true){
				if(cost[a][now]==1000000)sw = true;
				result.add(now);
				if(now==s)break;
				a = now;
				now=back[now];
			}
			return;
		}
		public AOJ0155(){
			Scanner in = new Scanner(System.in);
			while(true){
				n = in.nextInt();
				if(n==0)break;
				cost = new int[n+1][n+1];
				ban = new int[n+1];
				x = new int[n+1];
				y = new int[n+1];
				for(int i=1;i<n+1;i++){
					ban[i] = in.nextInt();
					x[ban[i]] = in.nextInt();
					y[ban[i]] = in.nextInt();
				}
				for(int i=1;i<n+1;i++){
					for(int s=i+1;s<n+1;s++){
						int x1 = x[i],y1= y[i],x2=x[s],y2=y[s];
						int costs = (int)Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));		
						cost[i][s] = costs > 50 ? 1000000:costs;
						cost[s][i] = cost[i][s];
					}
				}
				int kai = in.nextInt();
				for(int i=0;i<kai;i++){
					int s = in.nextInt();
					int g = in.nextInt();
					dijkstra(s, g);
//					if(sw){
//						System.out.println("NA");
//						break;
//					}
					for(int a=result.size()-1;a>=0;a--){
						System.out.print(result.get(a)+" ");
					}
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 17340
//____________________________________________________________________
  //________________________________NAMAN_______________________________
 //________________________________TALAYCHA______________________________
//__________________________________________________________________________

#include <bits/stdc++.h>
#define ll              long long
#define int             long long
#define pmin            priority_queue < ll, vector<ll>, greater<ll> >
#define pmax            priority_queue <ll>
#define endl            '\n'
#define mii             map<ll , ll >
#define pii             pair< ll, ll >
#define vi              vector<ll>
#define all(a)          (a).begin(), (a).end()
#define DEBUG           cerr<<"/n>>>I'm Here<<</n"<<endl;
#define rep(i, a, b )   for (ll i = a; i < b; i++)
#define rrep(i, a, b)   for (ll i = a; i >= b; i--)
#define bs              binary_search
#define present(c, x)   ((c).find(x) != (c).end())
#define cpresent(c, x)  (find(all(c), x) != (c).end())
#define p1(i)           cout<<i<<endl;
#define p2(i,j)         cout<<i<<" "<<j<<endl;
#define line            cout<<endl;
#define prt(s,b,n)      rep(i,(b),(n)) { cout<<(s)[i]<<" ";} line
#define lower(u)        transform(u.begin(), u.end(), u.begin(), ::tolower);  //convert string u to lowercase;
#define upper(u)        transform(u.begin(), u.end(), u.begin(), ::toupper);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define hell 1e6+3
#define mod 998244353

  using namespace std;

//_________________________________________________________________________________________________________
//__________________________________________START____________________________________________________________

//................EVERY COIN HAS TWO SIDES...............................................................................................................

void solve()
{
  ll n; 
  
  cin>>n;
  //for(ll i=0;i<n;i++)
  //string s;  cin>>s;
 vi a(n); rep(i,0,n){ cin>>a[i];}
  ll d[n+1];
  rep(i,0,n+1) d[i]=INT_MAX;
  d[0]=0;
  d[1]=0;
  d[2]=abs(a[0]-a[1]);
  rep(i,3,n+1)
  {
     d[i]=min(d[i-1]+abs(a[i-1]-a[i-2]),d[i-2]+abs(a[i-1]-a[i-3]));
  }
  cout<<d[n]<<endl;
  return;
}

//__________________________________________________________________________________________________________
//__________________________________________END______________________________________________________________

signed main() 
{

//sieve();
  ll TESTS = 1;
  //cin>>TESTS;
  while (TESTS--) 
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define Pct puts("------ Yes ------");
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
#define fir first
#define sec second
#define ls son[u][0]
#define rs son[u][1]
#define eps 1e-8
#define PI acos(-1.0)
using namespace std;
template <class T> void rd(T &x){ x = 0; int f = 1; char ch = getchar(); while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); x *= f; }

typedef long long ll;
const int N = 2e5 + 5;
ll f[N][5], a[N];
int n, s, m;

ll min3(ll a, ll b, ll c){ return min(min(a, b), c); }

void sol(){
	rep(i, 1, n){
		f[i][0] = f[i - 1][0];
		rep(j, 1, 4) f[i][j] = min(f[i - 1][j], f[i][j - 1]);
		f[i][0] += a[i];
		f[i][1] += (a[i] == 0 ? 2 : a[i] % 2);
		f[i][2] += (a[i] % 2 == 0);
		f[i][3] += (a[i] == 0 ? 2 : a[i] % 2);
		f[i][4] += a[i];
	}
	printf("%lld\n", min3(f[n][0], f[n][1], min3(f[n][2], f[n][3], f[n][4])));
}

int main(){
	rd(n);
	rep(i, 1, n) rd(a[i]);
	sol();
	return 0;
}

Measured memory_bytes: 9600
n = int(input())
a, b = map(int, input().split())
p = [int(i) for i in input().split()] 

s1 = []
s2 = []
s3 = []
for x in p:
    if x <= a:
        s1.append(x)
    elif x <= b:
        s2.append(x)
    else:
        s3.append(x)
print(min(len(s1), len(s2) ,len(s3)))

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    if (a[i] >= b[i]):
        ans += b[i]
    else:
        ans+=a[i]
        b [i]-= a[i]
        if (a[i+1] >= b[i]):
            ans += b[i]
            a[i+1]-=b[i]
        else:
            ans += a[i + 1]
            a[i + 1] = 0
print(ans)

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

int alpha[100];
int main(){
	for(int i=0;i<100;i++)alpha[i]=0;

	string s;	cin>>s;

	string ans="yes";
	for(int i=0;i<s.length();i++){
		if(alpha[s[i]-'a']==0)alpha[s[i]-'a']++;
		else {
			ans="no";
			break;
		}
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans,n,m;
int main(){
	cin>>n>>m;
	if(m==1){
		cout<<0;
		return 0;
	}
	int s=n;
	ans=1;
	n--;
	while(s<m){
		s=s+n;
		ans++;
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int h, w;
    scanf("%d %d", &h, &w);

    int cnt[5] = {0};
    // 4
    cnt[4] = (h / 2) * (w / 2);
    
    // 2
    if(h % 2 == 1) 
        cnt[2] += w / 2;
    
    if(w % 2 == 1)
        cnt[2] += h / 2;

    // 1 
    cnt[1] = (h % 2) && (w % 2);
    
    int freq[26] = {0};
    for(int i = 0; i < h; i++) {
        char inp[1111];
        scanf("%s", inp);
        for(int j = 0; j < w; j++) {
            int val = inp[j] - 'a';
            freq[val]++;
        }
    }
    
    bool ok = true;
    for(int i = 0; i < 26; i++) {
        if(freq[i] > 0) {
            while(cnt[4] > 0 && freq[i] >= 4) { 
                cnt[4]--;
                freq[i] -= 4;
            }
            while(cnt[2] > 0 && freq[i] >= 2) {
                cnt[2]--;
                freq[i] -= 2;
            }
            while(cnt[1] > 0 && freq[i] >= 1) {
                cnt[1]--;
                freq[i] -= 1;
            }

            if(freq[i] > 0)
                ok = false;
        }
    }

    printf("%s\n", ok ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto a = readln.chomp.to!int;
  auto b = readln.chomp.to!int;
  if ((a == 1 && b == 2) || (a == 2 && b == 1)) {
    writeln(3);
  } else if ((a == 1 && b == 3) || (a == 3 && b == 1)) {
    writeln(2);
  } else if ((a == 2 && b == 3) || (a == 3 && b == 2)) {
    writeln(1);
  }
}


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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long x, k, d;
    cin >> x >> k >> d;
    if (x < 0)
    {
        x = -x;
    }
    long long w = x / d;
    if (k <= w)
    {
        cout << x - d * k;
    }
    else
    {
        x -= w * d;
        k -= w;
        if (k & 1)
        {
            cout << d - x;
        }
        else
        {
            cout << x;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  int c=0;
  repeat(i,1,n-1) {
    if(p[i-1]<p[i]&&p[i]<p[i+1]) {
      c++;
    }
    if(p[i+1]<p[i]&&p[i]<p[i-1]) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
#再起のlimitを上げる
import sys
sys.setrecursionlimit(4100000)
S=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  S[a-1].append((b-1, i))
  S[b-1].append((a-1, i))

L=[0]*(N-1)


def dfs(node, pre_col,pre_node):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node)
    col+=1

dfs(0,-1,-1)

print(max(L))
for l in L:
  print(l)


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string str;
	cin >> str;
	cout << count(cbegin(str), cend(str), '1') << "\n";
}

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


Measured memory_bytes: 256
using System;
using System.Linq;

namespace CSharpScript
{
	class Program
	{
		static void Main(string[] args)
		{
			// Test("test");
        	var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
			var a = input[0];
			var b = input[1];
			var gcd = Gcd(input[0], input[1]);

			var ans = a * b /gcd;

			System.Console.WriteLine(ans);
		}

	public static long Gcd(long m, long n)
	{
		long temp;
		while (m % n != 0)
		{
			temp = n;
			n = m % n;
			m = temp;
		}
		return n;
	}
	}
}

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

int main() {
   int n,x;
   cin >> n >> x;
   int m[110],sum=0,mi=1100;
   rep(i,n){
   cin >> m[i]; 
   sum+=m[i]; mi=min(mi,m[i]);
   }
   cout << (x-sum)/mi+n << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=n;i>=1;i--){
    
    for(int j=0;j<=n-i;j++){
      bool ans=true;
      for(int k=j;k<=j+i-1;k++){
        if(!(s[k]=='A'||s[k]=='C'||s[k]=='G'||s[k]=='T'))ans=false;
      }
      if(ans){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  cout<<0<<endl;
}
        

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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

ll dp[101][100001];

int main(){
    ll N,W;
    cin >> N >> W;

    rep(i,N){
        rep(j,100001){
            dp[i][j] = INF;
        }
    }

    ll w,v;
    cin >> w >> v;
    dp[0][v] = w;

    for(int i=1; i<N; i++){
        cin >> w >> v;
        dp[i][v] = w;
        rep(j,100001){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j-v>=0) dp[i][j] = min({dp[i][j], dp[i-1][j-v]+w});
        }
        
    }

    repr(j,100001){  
        if(dp[N-1][j]<=W){
            cout << j;
            break;
        }
    }

}


Measured memory_bytes: 78336
#include <iostream>

using namespace std;

const unsigned long long mod = 1000000007uLL;

unsigned long long power(unsigned long long x, unsigned long long y) {
	if (y == 0) return 1uLL;
	if (y == 1) return x;
	unsigned long long t = power(x, y / 2);
	if (y % 2 == 1) return t * t % mod * x % mod; else return t * t % mod;
}

int main() {
	unsigned long long x, y;
	cin >> x >> y;
	cout << power(x, y)<<endl;
	return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
 
  long long ans = 0;
  int b = 0;
  int j = 0;
  for (int i = 0; i < N; i++) {
    while (j < N && (b & A[j]) == 0) {
      b ^= A[j];
      j++;
    }
    b ^= A[i];
    ans += (j - i);
  }
  cout << ans ;
}

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

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a);
  for (int i=0; i<a; i++) cin >> p[i];
  sort(p.begin(), p.end(), greater<int>());
  p.push_back(0);

  vector<int> q(b);
  for (int i=0; i<b; i++) cin >> q[i];
  sort(q.begin(), q.end(), greater<int>());
  q.push_back(0);

  vector<int> r(c);
  for (int i=0; i<c; i++) cin >> r[i];
  sort(r.begin(), r.end(), greater<int>());
  r.push_back(0);

  ll ans = 0;
  int aa = 0, bb = 0, cc = 0;
  while (aa+bb+cc < x+y){
    if (p[aa] > q[bb]){
      if (p[aa] >= r[cc] && aa < x) ans += p[aa++];
      else if (q[bb] >= r[cc] && bb < y) ans += q[bb++];
      else ans += r[cc++];
    }
    else{
      if (q[bb] >= r[cc] && bb < y) ans += q[bb++];
      else if (p[aa] >= r[cc] && aa < x) ans += p[aa++];
      else ans += r[cc++];
    }
  }
  cout << ans << endl;

  return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

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

    vi x(n);
    double p = 0;

    rep(i, 0, n) {
        cin >> x[i];
        p += x[i];
    }

    p /= double(n);

    double sum1 = 0, sum2 = 0;
    rep(i, 0, n) {
        sum1 += (x[i] - int(p)) * (x[i] - int(p));
        sum2 += (x[i] - int(p+1)) * (x[i] - int(p+1));
    }
    cout << min(sum1, sum2) << endl;

    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
  	cout << c << endl;
  }else if(a==c){
  	cout << b << endl;
  }else{
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import sys

N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

C = []

for i in range(0,N-1):
    for j in range(i, N):
        if j==i:
            C.append(A[i])
        else:
            C.append(C[-1] + A[j])

D = C
ans = 0
for i in range(40,-1,-1):
    yes = []
    no = []
    for l in D:
        if l & (1 << i):
            yes.append(l)
        else:
            no.append(l)

    if len(yes) >= K:
        ans += 1 << i
        D = yes

print(ans)

sys.exit(0)


Measured memory_bytes: 33256
import collections

N = int(input())
A = list(map(int, input().split()))

ctr_A = collections.Counter(A).most_common()
less_A = collections.Counter(A)

total = 0

for i in range(len(ctr_A)):
    n = ctr_A[i][1]
    total += n * (n - 1) // 2

for i in range(N):
    summ = total
    num = A[i]
    n = less_A[num]

    if (n == 2):
        summ -= 1
    else:
        new = (n - 1) * (n - 2) // 2
        old = n * (n - 1) // 2
        summ += new - old
    
    ans = max(0, summ)

    print(ans)


Measured memory_bytes: 34096
n = parse(Int, readline())

function cal(i, j, k)
  ans = gcd(gcd(i, j), k)

  if i == j == k
    ans
  elseif i == j || j == k || k == i
    ans * 3
  else
    ans * 6
  end
end

println(sum([
  cal(i, j, k)
  for i in 1:n
  for j in i:n
  for k in j:n
]))


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

int main()
{
	int n;	double odd = 0;
	cin >> n;
	if(n%2 == 0)
	{
		odd = n/2;
	}
	else
	{
		odd = ((n-1)/2)+1;
	}
	double ans;
	ans = odd/n;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;

struct node {
	int v;
    ll d;
    node(int v, ll d):v(v),d(d){}
    bool operator<(const node &n) const { return d > n.d; }
};
vector<pair<int,ll> > G[100005];
ll dist[100005];

void dijkstra(int s) {

	for(int i=0;i<100005;i++){
	dist[i]=-1ll;
	}
    priority_queue<node> que;
    que.push(node(s, 0ll));
    while(!que.empty()){
        int v = que.top().v;
		ll d = que.top().d;
        que.pop();
        if(dist[v] >= 0ll && dist[v] <= d) continue;
        dist[v] = d;
        for(int i = 0; i < G[v].size(); i++)
			que.push(node(G[v][i].first, d+G[v][i].second));
    }
}

int a[100005];
int b[100005];
ll c[100005];

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N-1;i++){
		scanf("%d %d %lld",&a[i],&b[i],&c[i]);
		G[a[i]].push_back(make_pair(b[i],c[i]));
		G[b[i]].push_back(make_pair(a[i],c[i]));
	}

	int Q,K;

	scanf("%d %d",&Q,&K);

	dijkstra(K);

	for(i=0;i<Q;i++){
	int x,y;
	scanf("%d %d",&x,&y);
	printf("%lld\n",dist[x]+dist[y]);
	}


	return 0;
}

Measured memory_bytes: 12656
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    long long a[20],b[20];
    a[0]=1;b[0]=1;
    for(int i=1;i<20;i++){
        a[i]=a[i-1]*4;
    }
    for(int i=1;i<20;i++){
        b[i]=b[i-1]+a[i];
    }
    int x=0;
    for(int i=17;i>0;i--){
        if(n>b[i-1]&&b[i]>=n){
            printf("1");
            x=1;
            n-=a[i];
        }
        else if(x)printf("0");
        if(n>=0-(b[i]-1)/2&&0-(b[i-1]+1)/2>=n){
            printf("1");
            x=1;
            n+=a[i]/2;
        }
        else if(x)printf("0");
    }
    printf("%d\n",n);
}

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

int main()
{
	int n;
	long long x,y,a,b,c,d;
	cin>>n>>x>>y;
	for(int i=1;i<n;i++)
	{
		cin>>a>>b;
		c=(x+a-1)/a;
		d=(y+b-1)/b;
		x=max(c,d)*a;
		y=max(c,d)*b;
	}
	cout<<x+y;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int A,B,s,a[5];
  cin>>A>>B;
  s=0;
  int k;
  for(int i=A;i<B+1;i++){
    k=i;
    for(int j=0;j<5;j++){
      a[j]=k%10;
      k=(k-k%10)/10;
    }
    if(a[0]==a[4] && a[1]==a[3])
      s++;
  }
  cout<<s<<endl;
}
  

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> vec;
  int temp;
  for (int i=0;i<N;i++){
    cin >> temp;
    vec.push_back(temp);
  }
  //cout << vec.size() <<endl;                                                                                                                                
  //cout << vec[0] <<endl;                                                                                                                                    

 //左から順に見ていって，1，２，３，４，，，となるように削除していけば良い．                                                                                 
  int K=0;
  int count=0; //これが答え                                                                                                                                   
  int ans=1; //数列1，２，３，に対応する数字                                                                                                                  
  for (int i=0;i<N;i++){
    if(vec[i]!=ans){
      count+=1;
    }else{
      ans+=1;
    }
  }
  if(count==N){
    count=-1;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(){
  string week[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string today;
  cin >> today;
  int day = 7;
  for(int i=0; i<7; i++){
    if (week[i]==today) day-=i;
  }
  cout << day;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int a,b;
    cin>>a>>b;
    if(b%a)cout<<(b-a)<<endl;
    else cout<<(b+a)<<endl;
    return 0;
}


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

int main(void){
  typedef pair<int,int> pair;
  int n; cin >> n;
  int p[n];
  rep(i,n) cin >> p[i];
  int ans = 1;
  int min = p[0];
  for(int i = 1; i < n; i++){
    if(p[i] <= min){
      ans++;
      min = p[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> d(k);
	for(int i = 0; i < k; i++){
		cin >> d[i];
	}

	for(int x = n; x < 100000; x++){
		int tmp = x;
		set<int> s;
		while(tmp!=0){
			s.insert(tmp%10);
			tmp /= 10;
		}
		bool flag = true;
		
		for(int i = 0; i < k; i++){
			if(s.count(d[i])) flag = false;
		}
		if(flag){
			cout << x << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

H, W, N = map(int, input().split())
dct = {}
for i in range(N):
    a, b = map(lambda x: int(x) - 1, input().split())
    for x in range(3):
        for y in range(3):
            if 0 <= a - y < H - 2 and 0 <= b - x < W - 2:
                p = (a - y, b - x)
                dct[p] = 1 if (p not in dct) else dct[p] + 1

cnt = [0] * 10
for n in dct.values():
    cnt[n] += 1
cnt[0] = (H - 2) * (W - 2) - len(dct)

for i in cnt:
    print(i)


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

int main(){
  int n, k, x, y, ans;
  cin >> n >> k >> x >> y;
  ans = 0;
  for(int i = 1; i <= n; i++){
    if(i > k) ans += y;
    else ans += x;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int i,n,tmp;
    char c;
    int S[13],H[13],C[13],D[13];
    
    for(i=0;i<13;i++){
        S[i]=H[i]=C[i]=D[i]=0;
    }
    
    scanf("%d",&n);
    
    for(i=0;i<2*n;i++){
        scanf("%c",&c);
        scanf("%d",&tmp);
        
        if(c=='S'){
            S[tmp-1]=1;
        }else if(c=='H'){
            H[tmp-1]=1;
        }else if(c=='C'){
            C[tmp-1]=1;
        }else if(c=='D'){
            D[tmp-1]=1;
        }
    }
    
    for(i=0;i<13;i++){
        if(S[i]==0){
            printf("S %d\n",i+1);
        }
    }
    
    for(i=0;i<13;i++){
        if(H[i]==0){
            printf("H %d\n",i+1);
        }
    }
    
    for(i=0;i<13;i++){
        if(C[i]==0){
            printf("C %d\n",i+1);
        }
    }
    
    for(i=0;i<13;i++){
        if(D[i]==0){
            printf("D %d\n",i+1);
        }
    }
    
    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
  int a = 0;
  int k = 0;
  cin >> a >> k;
  vector<double> b(a);
  for(int i = 0;i <= a - 1;i++){
    cin >> b[i];
  }
  double saidai = 0;
  double syoukei = 0;
  for(int i = 0;i <= k - 1;i++){
    syoukei += b[i];
  }
  for(int i = 0;i <= a - k;i++){
    if(i >= 1){
      syoukei = syoukei - b[i - 1] + b[i + k - 1];
    }
    if(syoukei >= saidai){
      saidai= syoukei;
    }
  }
  double kotae = (saidai + k) / 2;
  cout << fixed << setprecision(6) << kotae << endl;
  return 0;
}



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


int p[10][10][10], q[10][10], r[10];

int main() {
       int n; cin >> n; string str; cin >> str;
       for(int i = n - 1; i >= 0; i--) {
            for(int j = 0; j < 10; j++) {
                for(int k = 0; k < 10; k++) {
                    p[str[i] - '0'][j][k] |= q[j][k];
                }
            }
            for(int j = 0; j < 10; j++) q[str[i] - '0'][j] |= r[j];
            r[str[i] - '0'] = 1;
       }

       int cnt = 0;

       for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                for(int k = 0; k < 10; k++) cnt += p[i][j][k];
            }
       }
       cout << cnt << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1], K = l[2];
            for (var i = 0; i <= N; i++) {
               for (var j = 0; j <= M; j++) {
                  if (i*j+(N-i)*(M-j)==K) {
                     Console.WriteLine("Yes");
                     return; 
                  } 
               } 
            }
                
            Console.WriteLine("No");
        }
    }
}


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

public class Main {

	static Doll[] d;
	static int[][] memo;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int N = cin.nextInt();
			if(N==0){
				break;
			}
			int maxh=0,maxr=0;
			Doll[] tmp = new Doll[N];
			for(int i = 0;i<N;i++){
				int a = cin.nextInt();
				int b = cin.nextInt();
				maxh=Math.max(maxh,a);
				maxr=Math.max(maxr,b);
				tmp[i]=new Doll(a,b);
			}

			N = N + cin.nextInt();
			d = new Doll[N];
			for(int i = 0;i<tmp.length;i++){
				d[i]=tmp[i];
			}

			for(int i = tmp.length;i<N;i++){
				int a = cin.nextInt();
				int b = cin.nextInt();
				maxh=Math.max(maxh,a);
				maxr=Math.max(maxr,b);
				d[i]=new Doll(a,b);
			}
			Arrays.sort(d);
			memo = new int[maxh+1][maxr+1];
			for(int i = 0;i<maxh+1;i++){
				for(int j = 0;j<maxr+1;j++){
					memo[i][j]=-1;
				}
			}
			for(int i = 0;i<N;i++){
				//System.out.println(d[i].h + " " + d[i].r);
			}
			int max = 0;
			for(int i = 0;i<d.length;i++){
				max = Math.max(max, search(d[i].h,d[i].r));
			}
			System.out.println(max);
		}

	}
	static int search(int h,int r){
		//System.out.println(h+" " +r);
		int hh=0, rr=0, max=0;
		for(int i =0;i<d.length;i++){
			if(d[i].h >= h || d[i].r >= r){
				continue;
			}
			else{
				hh=d[i].h;
				rr=d[i].r;
				if(memo[hh][rr]==-1){
					memo[hh][rr]=search(hh,rr)+1;
				}
				max = Math.max(memo[hh][rr], max);
			}
		}
		if(hh==0&&rr==0){
			return 1;
		}
		return max;
	}
}

class Doll implements Comparable{
	int h;
	int r;
	Doll(int a,int b){
		h=a;
		r=b;
	}
	public int compareTo(Object o){
		Doll d = (Doll)o;
		if(this.h==d.h){
			return this.r-d.r;
		}
		else{
			return this.h-d.h;
		}
	}
}

Measured memory_bytes: 17000
#include<iostream>
using namespace std;
int main(){

  int A,B,C,D,L,Amin,Bmin;

  cin >>L>>A>>B>>C>>D;

  Amin=A/C;
  Bmin=B/D;

  if(A%C != 0)
    Amin++;
  if(B%D != 0)
    Bmin++;

  if( Amin >= Bmin ){
    cout <<L-Amin<<endl;
  }else{
    cout <<L-Bmin<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int MAX_N=1000;

int N,M;
int P[MAX_N];

int comb[MAX_N*MAX_N];

vector<int> out;

int main(){
	do{
		scanf("%d %d",&N,&M);
		if (N!=0 || M!=0){
			int i,j;
			for (i=0;i<N;i++){
				scanf("%d",&P[i]);
			}
			for (i=0;i<N;i++){
				for (j=0;j<N;j++){
					comb[i*N+j]=P[i]+P[j];
				}
			}
			sort(comb,comb+N*N);
			int ma=0;
			//???????????´???
			for (i=0;i<N;i++){
				if (P[i]<=M){
					ma=max(ma,P[i]);
				}
			}
			//???????????´???
			int *p;
			p=upper_bound(comb,comb+N*N,M);
			if (p!=comb){
				ma=max(ma,*(p-1));
			}
			//???????????´???
			for (i=0;i<N;i++){
				p=upper_bound(comb,comb+N*N,M-P[i]);
				if (p!=comb){
					ma=max(ma,P[i]+*(p-1));
				}
			}
			//???????????´???
			for (i=0;i<N;i++){
				for (j=0;j<N;j++){
					p=upper_bound(comb,comb+N*N,M-P[i]-P[j]);
					if (p!=comb){
						ma=max(ma,P[i]+P[j]+*(p-1));
					}
				}
			}
			out.push_back(ma);
		}
	}while (N!=0 || M!=0);
	for (int i=0;i<out.size();i++){
		printf("%d\n",out[i]);
	}
	return 0;
}

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

typedef long long  LL;
const int mo=int(1e9+7);
int n,m,a[16],b[16],c[1<<15],f[1<<15],ans;

void work()
{
	scanf("%d %d",&n,&m);
	for (int i=1,x,y; i<=m; i++)
		scanf("%d %d",&x,&y),a[x]|=1<<(y-1),b[y]|=1<<(x-1);
	for (int i=1; i<(1<<n); i++)  c[i]=c[i/2]+(i&1);
	f[0]=1;
	for (int i=1; i<(1<<n); i++)
		for (int j=i; j; j=(j-1)&i)
			if (c[j&3]!=1)
				{
					LL s=1;
					for (int k=1; k<=n; k++)
						{
							if (j&(1<<(k-1)))  (s<<=c[b[k]&(i^j)])%=mo;
							if (!(i&(1<<(k-1))))  s=s*((1<<c[a[k]&j])-1)%mo;
						}
					f[i]=(f[i]+f[i^j]*s)%mo;
				}
	ans=1;
	for (int i=1; i<=m; i++)  (ans<<=1)%=mo;
	printf("%d",(ans+mo-f[(1<<n)-1])%mo);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    const double pi=3.14159265358979323846;
    long double A,B,H,M;cin>>A>>B>>H>>M;
    long double minutes=H*60+M;
    long double x=minutes/720,y=M/60;
    if(x==0)x=1;if(y==0)y=1;
    long double n=(max(x,y)*2*pi)-(min(x,y)*2*pi);
    long double z=max((B-A*cos(n)),(A*cos(n)-B));
    long double ans=sqrt(z*z+(A*sin(n))*(A*sin(n)));
    cout<<fixed<<setprecision(20)<<ans<<endl;
}

Measured memory_bytes: 4172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	vl v(3); cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	cout << (v[0] + v[1]) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();

        var n = sc.nextInt();
        var a = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.nextInt() * 2;
        }
        var b = new long[n];
        b[0] = 0;
        for (int i = 0; i < n - 1; i++)
        {
            b[i + 1] = a[i] - b[i];
        }

        if (a[n - 1] != b[n - 1] + b[0])
        {
            b[0] = (a[n - 1] - b[n - 1]) / 2;
            for (int i = 0; i < n - 1; i++)
            {
                b[i + 1] = a[i] - b[i];
            }
        }

        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        for (int i = 0; i < b.Length; i++)
        {
            if (i != 0) Console.Write(" ");
            Console.Write(b[i]);
        }
        Console.Write("\n");
        Console.Out.Flush();
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 32088
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String S = sc.next();
		System.out.println(S.substring(0, K - 1) + S.substring(K - 1, K).toLowerCase() + S.substring(K));
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;

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; }
const long MAX = 100000;
const long MOD = 1000000007;


bool a(string S){
    string S_ = S;
    reverse(S_.begin(),S_.end());
    for(ll i=0;i<S.size();i++){
        if(S[i]!=S_[i]){
            return false;
        }
    }
    return true;
}

int main(){
    string S;
    cin>>S;
    bool flag1 = a(S);
    string s0 = S.substr(0,(S.size()-1)/2);
    bool flag2 = a(s0);
    string s1 = S.substr((S.size()-1)/2+1,(S.size()-1)/2);
    bool flag3 = a(s1);
    cout<<((flag1&flag2&flag3)?"Yes":"No")<<endl;
    

    
}

Measured memory_bytes: 256
h = input()
A = map(int, raw_input().split())[::-1]

l = 2
r = 2

def ng():
  print "-1"
  exit()

for a in A:
  l = l / a * a + (l % a != 0) * a
  r = r / a * a
  if r < l:ng()
  r += a-1

print l, r

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

int main(){
    string s1,s2;   cin>>s1>>s2;
    if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let s = get!(String);
    let v: Vec<char> = s.chars().collect();
    if v.len() == 2 {
        if v[0] == v[1] {
            println!("1 2");
            return;
        } else {
            println!("-1 -1");
            return;
        }
    }
    for i in 0..v.len() - 2 {
        if v[i] == v[i + 1] {
            println!("{} {}", i + 1, i + 2);
            return;
        } else if v[i] == v[i + 2] {
            println!("{} {}", i + 1, i + 3);
            return;
        }
        if i == v.len() - 3 {
            if v[i + 1] == v[i + 2] {
                println!("{} {}", i + 2, i + 3);
            }
        }
    }
    println!("-1 -1");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool comp(const int& a, const int& b) {
	return a > b;
}

int main()
{
	double N;
	cin >> N;
	cout << ceil(N / 2) << endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s, ans string
	fmt.Scan(&s)
	for _, v := range s {
		if v == '0' || v == '1' {
			ans += string(v)
		} else if len(ans) > 0 {
			ans = ans[:len(ans)-1]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512