akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
typedef long long ll;
#define inf 1LL<<60
using namespace std;
#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
int main(void){
    int n,k,h[305];
    cin >> n >> k;
    for(int x=1;x<=n;x++){
        cin >> h[x];
    }
    ll dp[305][305];
    for(int i=0;i<305;i++) for(int j=0;j<305;j++) dp[i][j] = inf;
    dp[0][0] = 0;
    for(int x=0;x<=n;x++){
        for(int y=1;y<=n-k;y++){
            for(int z=0;z<=x-1;z++){
                dp[x][y] = min(dp[x][y],dp[z][y-1]+max(0,h[x]-h[z]));
            }
        }
    }
    ll ans = inf;
    for(int z=1;z<=n;z++){
        ans = min(ans,dp[z][n-k]);
    }if(n==k) ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int c = 0;
	for (int i = 0; i < N; ++ i) {
		int x;
		cin >> x;
		if (x % 2) ++ c;
	}
	cout << (c % 2 == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cstring>
#include <algorithm>

using i32 = std::int_fast32_t;

const int MaxN = 100001;

int A[MaxN][3], dp[MaxN][3];

signed main(signed argc, char **argv) {
	i32 n;
	std::scanf("%" SCNdFAST32, &n);
	
	for (i32 i = 0; i < n; ++ i) {
		std::scanf("%" SCNdFAST32 "%" SCNdFAST32 "%" SCNdFAST32, A[i], A[i] + 1, A[i] + 2);
	}
	
	memset(dp, 0, sizeof dp);
	
	dp[0][0] = A[0][0];
	dp[0][1] = A[0][1];
	dp[0][2] = A[0][2];
	
	for (i32 i = 1; i < n; ++ i) {
		for (i32 j = 0; j < 3; ++ j) {
			for (i32 a = 0; a < 3; ++ a) {
				if (a == j) {
					continue;
				}
				dp[i][j] = std::max(dp[i][j], dp[i - 1][a] + A[i][j]);
			}
		}
	}
	
	std::printf("%" PRIdFAST32, std::max(dp[n - 1][0], std::max(dp[n - 1][1], dp[n - 1][2])));
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int n;
map <pi, set <pi>> adj;
map <pi, int> visited;
vpi edges, topo;
inline pi coo (int x, int y) {return {min(x, y), max(x, y)};}

void input()
{
    cin >> n;
    FOR (i, 1, n)
    {
        READ(x);
        edges.pb(coo(x, i));
        FOR (j, 1, n - 2)
        {
            READ(y);
            edges.pb(coo(y, i));
            adj[coo(x, i)].insert(coo(y, i));
            x = y;
        }
    }
}

void dfs (pi cur)
{
    visited[cur] = 1;
    for (pi i: adj[cur])
    {
        if (!visited[i])
            dfs(i);
        
        else if (visited[i] == 1)
        {
            cout << -1;
            exit(0);
        }
    }
    
    visited[cur] = 2;
    topo.pb(cur);
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	input();
	
	for (pi i: edges)
        if (!visited[i])
	        dfs(i);
	        
	reverse(topo.begin(), topo.end());
	
	int last[n + 1] = {}, ans = 0;
	for (pi i: topo)
	{
	    int x = max(last[i.fi], last[i.se]);
	    last[i.fi] = last[i.se] = x + 1;
	    ans = max({ans, last[i.fi], last[i.se]});
	}
	
	cout << ans;
}

Measured memory_bytes: 172388
# -*- coding: utf-8 -*-
n = int(input());
mochi = [];
for x in range(n):
    n = int(input());
    mochi.append(n);


mochi.sort(reverse=True)
dan = 0;
low = 101;
for x in mochi:
    if x < low:
        dan += 1;
        low = x;
print(dan);

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	REP(i, n) cin >> h[i];

	sort(ALL(h));
	
	int min = INF;
	REP(i, n-k+1){
		if ((h[i+k-1] - h[i]) < min) min = h[i+k-1]-h[i];
	}

	cout << min << endl;

}


Measured memory_bytes: 640
#include <algorithm>
#include <chrono>
#include <iostream>
#include <vector>

using namespace std;
using namespace std::chrono;

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b;
  char sgn;

  cin >> a >> sgn >> b;
  cout << (sgn == '-' ? a - b : a + b) << endl;


  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


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

const int N = 5;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
const char C[] = {'R','D','L','U'};
int g[N][N];

int main() {
  fill(g[0], g[N], 0);
  for(int s = 0; s < 2*N-1; ++s) {
    for(int j = 0; j < N-1+s%2; ++j) {
      int i = s/2;
      char a;
      cin >> a;
      if(a == '1') {
	if(s%2 == 0) {
	  g[i][j] |= (1<<0);
	  g[i][j+1] |= (1<<2);
	} else {
	  g[i][j] |= (1<<1);
	  g[i+1][j] |= (1<<3);
	}
      }
    }
  }

  int i, j, d;
  i = j = 0;
  d = 0;
  do {
    for(int k = 0; k < 4; ++k) {
      int nd = (d+3+k)%4;
      if(g[i][j] & (1<<nd)) {
	d = nd;
	i += di[d];
	j += dj[d];
	cout << C[d];
	break;
      }
    }
  } while(!(i == 0 && j == 0));
  cout << endl;
  return 0;
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	string s; cin>>s;
	if(s[0]==s[1]&&s[1]==s[2]&&s[0]==s[2]) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;

const int MAXN=100000+10;

map<int,int> mp;
set<int> s;

int a[MAXN];

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s.find(a[i])!=s.end())continue;
		else if(s.find(a[i])==s.end()){	
			s.insert(a[i]);
			if(mp[a[i]]<a[i]){
				cnt+=mp[a[i]];
			}
			if(mp[a[i]]>a[i]){
				cnt+=mp[a[i]]-a[i];
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		  Scanner sc = new Scanner(System.in);
          Long n = sc.nextLong();
    Long money = 100L;
    int y = 0;
    while(money < n){
      money += money/100;
      y++;
    }
    System.out.println(y);
    }
}

Measured memory_bytes: 35792
#include <iostream>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int a, b[10001];
	long long int max , min , sum = 0 ;

	cin >> a;
	

	for (int i = 0; i < a; i++) {
		cin >> b[i];
		if (i == 0) {
			min = b[i];
			max = b[i];
		}

		if (b[i] < min)
		{
			min = b[i];
		}
		else if(max < b[i]){
			max = b[i];
		}

		sum += b[i];
	}
	cout <<min<< " " <<max<< " " << sum << endl;


	return 0;
}



Measured memory_bytes: 3144
import math
url = "https://atcoder.jp//contests/abc052/tasks/arc067_a"


def get_list_eratosthenes(n):
    if n < 2:
        return [0]*(n+1)
    prime = [1]*(n+1)
    prime[0] = prime[1] = 0
    for i in range(2, int(n**0.5) + 1):
        if not prime[i]: continue
        for j in range(i * 2, n + 1, i):
            prime[j] = 0
    return prime


def main():
    N = int(input())
    tmp = N
    primes = get_list_eratosthenes(N)
    ans = 1
    for p in range(2, N+1):
        if primes[p] == 0: continue
        cur = p
        num = 0
        while cur <= N:
            num += N // cur
            cur *= p
        ans *= (num + 1)
        ans %= 10**9+7
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9404
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong p) {
	int i=0;
	for(int j = 0; j < k; j++ ) {
		llong sum = 0;
		while( sum + T[i] <= p) {
			sum += T[i];
			i++;
			if(i == n ) return n;
		}
	}
	return i;
}

int solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while(left < right) {
		mid = (left + right) / 2;
		int v = check(mid);
		if(v == n) right = mid;
		else left = mid+1;
	}
	return right;
}

main() {
	cin >> n >> k;
	for( int i = 0; i < n; i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, x;
    cin>>n>>m>>x;
    
    int c[n];
    int a[n][m];
    f1(i,0,n)
    {
        cin>>c[i];
        f1(j,0,m)
        cin>>a[i][j];
    }

    int ans = mod;
    int num = 1ll<<n;
    
    for(int i = 0; i < num; i++)
    {
        int cost = 0;
        int arr[m];
        memset(arr, 0, sizeof(arr));

        for(int j = 0; j < n; j++)
        {
            if( (i & (1ll<<j)) > 0)
            {
                cost+=c[j];
                f1(k,0,m)
                arr[k] += a[j][k];
            }
        }
        int flag = 1;
        f1(j,0,m)
        if(arr[j] < x)
            flag = 0;
        
        if(flag)
        ans = min(ans, cost);

    }
    if(ans == mod)
    cout<<-1<<endl;
    else
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    string s; cin >> s;
    if (s == "Sunny"){
        cout << "Cloudy" << endl;
        return 0; 
    } else if (s == "Cloudy"){
        cout << "Rainy"<< endl;
        return 0;
    } else {
        cout << "Sunny" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
    
	ll n,i,j,p,k,m,ans=0;
    cin>>n>>m;
    vector<ll> a(n);
    ll b,c;
    vector<pair<ll,ll> > v;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i];
    }
    
    for(i=0;i<m;i++)
    {
        cin>>b>>c;
        v.pb({c,b});
    }
    
    sort(a.begin(),a.end());
    sort(v.begin(),v.end(),greater<pair<ll,ll>>());
    j=0;
    for(i=0;i<m;i++)
    {
        b=v[i].S;
        c=v[i].F;
        ll tmp=0;
        while(tmp<b && a[j]<c)
        {
            a[j]=c;
            tmp++;j++;
            if(j==n)
            break;
        }
        if(j==n)
        break;
    }
    
    ans=0;
    for(i=0;i<n;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 6108
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    int X[N];
    int S[N];
    for(int i=0; i<N; i++) {
        cin >> X[i];
        S[i] = X[i];
    }
    sort(S, S + N);
    int med1 = S[N/2-1];
    int med2 = S[N/2];
    for(int i=0; i<N; i++){
        if(X[i] >= med2) cout << med1 << endl;
        else cout << med2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	while(N){
		if(N%10==7){
			cout<<"Yes"<<endl;
			return 0; 
		}
		N=N/10;
	}
	cout<<"No"<<endl;
	return 0;
} 

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

int main(){
    string s;
    cin >> s;

    int count = 0;
    for(int i = 0; i < s.length(); i++){
        int cores = 0;
        for(; i+cores < s.length(); cores++){
            if(!(s[i+cores] == 'A' || s[i+cores] == 'C' || s[i+cores] == 'G' || s[i+cores] == 'T')){
                break;
            }
        }

        if(cores > count) count = cores;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;
long long T;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

int main() {
    cin >> N;
    long long ret = 1;
    for (int i = 0; i != N; ++i) {
        cin >> T;
        ret = lcm(ret, T);
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String args[])throws IOException,NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		int sum;//????¨????????¨????????????¨
		char c;
		sum = 0;
		
		while(true){
			str=br.readLine();
			
			//String??????long????????????
			if(str.length() == 1){
				if(Integer.parseInt(str) == 0){
				break;
				}
			}
			//?????????????????????
			for(int count = 0;count<str.length();count++){
				//????????????????????????????????????????¶?????????????
				c = str.charAt(count);
				//Char??????String??????Long??????????????????????¨?????¶?????????????
				sum += Integer.parseInt(String.valueOf(c));
			}
		sb.append(sum);
		sb.append("\n");
		sum = 0;//?????????
		}
		
		//????????????????????????????????????("\n")?????¨???
		sb.deleteCharAt(sb.length()-1);
		System.out.println(new String(sb));
		
	}
}

Measured memory_bytes: 24728
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;

	int n; cin >> n;
	int arr[n];
	int xor_val = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		xor_val ^= arr[i];
	}

	for (int i = 0; i < n; i++)
		cout << (arr[i]^xor_val) << " ";
	cout << endl;

	return 0;
}

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

int main() {
  string o, e; cin >> o >> e;
  for (int i = 0; i < o.size() + e.size(); i++) {
    if (i % 2 == 0) cout << o[i / 2];
    else cout << e[i / 2];
  }
  cout << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N,R;
    cin >> N >> R;
    if(N>=10) cout << R << endl;
    else cout << R+100*(10-N) << endl;
}

Measured memory_bytes: 256
'use strict'
const main = (input: string) => {
    const std: string[] = input.split(' ')
    const n = ~~std.shift()
    const m = ~~std.shift()
    console.log(n-m === 0 ? 'Yes' : 'No')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


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

vector<int> adj[100005];
int n,m;

int level[100005];
int dfs(int source){
    if(level[source]!=-1) return level[source];
    int res=0;
        for(int i=0;i<adj[source].size();i++){
            int v;
            v=dfs(adj[source][i]);
            res=max(res,v);
    }
    res++;
    level[source]=res;
    return res;
   
}
int main(){
   
     memset(level,-1,sizeof(level));
    cin >> n >> m;
    while(m--){
        int a,b;
        cin >> a >> b;
        adj[a].push_back(b);
    }
    vector<int> xoxo;
    for(int i=1;i<=n;i++){
        xoxo.push_back(dfs(i));
    }
    sort(xoxo.begin(),xoxo.end(),greater<int>());
    
    cout << xoxo[0]-1 << endl;
    
   
    
}

Measured memory_bytes: 11552
N = int(input())
A = []; B = []
for i in range(N):
  x,y = map(int,input().split())
  a = x+y; A.append(a)
  b = x-y; B.append(b)
A.sort();B.sort()
Max_A = A[-1] - A[0]
Max_B = B[-1] - B[0]
ans = max(Max_A,Max_B)
print(ans)

Measured memory_bytes: 25720
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] ary=new int[n];
		for(int i=0; i<ary.length; i++) {
			ary[i]=sc.nextInt();
		}
		Arrays.sort(ary);
		long sum=0;
		for(int i=0; i<ary.length; i++) {
			sum+=ary[i];
		}
		System.out.printf("%d %d %d%n",ary[0],ary[n-1],sum);
	}
	
}



Measured memory_bytes: 43292
import Foundation

let number = readLine()!.componentsSeparatedByString(" ")

let N = Int(number[0])!

func divisors(N: Int) -> [Int] {
  var result: [Int] = []
  var i = 1
  while i * i <= N {
    if N % i == 0 {
      result.append(i)
      if i * i != N {
        result.append(N / i)
      }
    }
    i += 1
  }
  return result
}

let case1 = divisors(N)

var ans = 0
for num in case1 {
  if num == 1 {
    continue
  }
  var tmp = N
  while tmp % num == 0 {
    tmp /= num
  }
  if tmp % num == 1 {
    ans += 1
  }
}

ans += divisors(N-1).count - 1
print(ans)

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdint.h>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int ,int> pp;
typedef long long ll;
const ll MOD = 1000000007;

int main(){
    int x, y;
    cin>>x>>y;
    int ans = 0;
    if(x == 1) ans +=300000;
    if(x == 2) ans +=200000;
    if(x == 3) ans +=100000;
    if(y == 1) ans +=300000;
    if(y == 2) ans +=200000;
    if(y == 3) ans +=100000;
    if(ans == 600000) ans +=400000;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[3005][3005] = {};

int main() {
    nfs
    ll total = 0;
    int i, j, n;
    string s;
    
    cin >> n >> s;
    
    dp[n][1] = 1;
    for (i = n-1; i; i--) {
        ll part = 0;
        if (s[i-1] == '>') {
            for (j = 1; j <= n-i+1; j++) {
                dp[i][j] = part;
                part = (part + dp[i+1][j]) % mod;
            }
        }
        else {
            for (j = n-i+1; j; j--) {
                dp[i][j] = part;
                part = (part + dp[i+1][j-1]) % mod;
            }
        }
    }

    for (j = 1; j <= n; j++) {
        total =  (total + dp[1][j]) % mod;
    }
    
    cout << total;

}

Measured memory_bytes: 49684
main :: IO ()
main = interact $ unlines . map show . solve . reverse . drop 3 . reverse . words

solve :: [String] -> [Int]
solve [] = []
solve (a:x:b:xs)
    | x == "+" = k + l : ys
    | x == "-" = k - l : ys
    | x == "*" = k * l : ys
    | x == "/" = k `div` l : ys
    where
        k = (read :: String -> Int) a
        l = (read :: String -> Int) b
        ys = solve xs


Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x=0,k=1; char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')k=-1;c=getchar();}
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*k;
}
int n,l,all,a[210];
int main(){
	n=read(),l=read();
	for(int i=1;i<=n;i++)a[i]=l+i-1,all+=a[i];
	int ans=0,minn=1e8;
	for(int i=1;i<=n;i++){
		int now=all-a[i];
		if(abs(all-now)<minn)minn=abs(all-now),ans=now;
	}
	cout<<ans;
}

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

using namespace std;

using ll = long long;
using ld = long double;

ll n, m, k;
vector <vector <ll>> vec;
vector <ll> add;
vector <ll> ans;
vector <bool> used;

const ll INF = 1e9;

void dfs(int v, int cur = 0) {
//	cout << v << '\n';
	ans[v] = add[v] + cur;
	cur += add[v];
	used[v] = true;
	for (int i = 0; i < vec[v].size(); ++i) {
		if (!used[vec[v][i]]) {
			dfs(vec[v][i], cur);
		}
	}
}

int main() {
	cin >> n >> k;
	vec.resize(n);
	add.resize(n, 0);
	ans.resize(n, 0);
	used.resize(n, false);
	int v, to;
	for (int i = 0; i < n - 1; ++i) {
		cin >> v >> to;
		--v; --to;
		vec[v].push_back(to);
		vec[to].push_back(v);
	}
	for (int i = 0; i < k; ++i) {
		cin >> v >> to;
		--v;
		add[v] += to;
	}
	dfs(0);
	for (auto &x : ans) {
		cout << x << ' ';
	}
	return 0;
}

Measured memory_bytes: 25856
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ h, n ] <- readInts
	as <- readInts
	putStrLn $ which "Yes" "No" $ h <= sum as

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main()
{
	map<ll,ll> mp;
	ll res = 0,ans=0,p=1;
	mp[0]++;
	string s;
	cin>>s;
	for(int i=s.size()-1;i>=0;i--)
	{
		res = ((s[i]-'0')*p+res)%2019;
		ans+=mp[res];
		mp[res]++;
		p = (p*10)%2019;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

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

    if(n == m){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;  
    }
}

    

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    set<int> S;
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(S.find(a)!=S.end()){
            cout<<"NO"<<endl;
            return 0;
        }
        S.insert(a);
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    if (n < 1000) OUT("ABC")
    else OUT("ABD")

    return 0;
}

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

#define lint long long
#define P pair<int, int>

int main() {
    lint N, K;
    cin >> N >> K;
    
    lint A[N];
    
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    int bits = 0;
    
    while(((lint)1<<bits) <= K){
        bits++;
    }
    lint num[bits];
    lint ans = 0;
    lint cnt[bits];
    
    for(int i = 0; i < bits; ++i){
        num[i] = 0;
    }
    for(int i = 0; i < bits; ++i){
        cnt[i] = 0;
    }
    
    
    for(int b = bits - 1; b >= 0; --b){
        for(int i = 0; i < N; ++i){
            cnt[b] += (A[i] >> b) & 1;
        }
    }
    
    for(int i = bits - 1; i >= 0; --i){
        if(((K >> i) & 1) == 0){
            continue;
        }
        
        for(int b = bits - 1; b >= 0; --b){
            if(b > i){
                num[i] += ((lint)1 << b) * ((K >> b) & 1);
            }
            if(b < i){
                num[i] += ((lint)1 << b) * (cnt[b] < N - cnt[b]);
            }
        }
        lint temp = 0;
        for(int j = 0; j < N; ++j){
            temp += num[i]^A[j];
        }
        
        ans = max(temp, ans);
    }
    
    lint temp = 0;
    for(int j = 0; j < N; ++j){
        temp += K^A[j];
    }
    ans = max(temp, ans);
    
    cout << ans << endl;
}
    

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

int main() {
	int n, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2) cnt++;
        else cnt = 0;
        if(cnt == 3) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
  	cin >> n >> m;
  	int sum = 0;
  	for (int i = 0; i < m; i++) {
     	int x; cin >> x;
      	sum += x;
    }
  	if (sum > n) cout << -1 << endl;
  	else cout << n - sum << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>

static const int N = 100;

int min(int x, int y){return x<y ? x:y;}

int main(){
  int i,j,k,l,v;
  int n,P[N+1],M[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&P[i-1],&P[i]);
  }

  for(i=1;i<=n;i++) M[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=0;i<=n-l+1;i++){
      j=i+l-1;
      M[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
	M[i][j] = min(M[i][j], M[i][k] + M[k+1][j] + P[i-1]*P[k]*P[j]);
	v = M[i][k] + M[k+1][j] + P[i-1]*P[k]*P[j];
      }
    }
  }
  printf("%d\n",M[1][n]);
  
  return 0;
}



Measured memory_bytes: 2056
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a,b,x = IN()
	rb=b//x
	ra=(a-1)//x
	ret= rb-ra
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

Measured memory_bytes: 256
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    if A-1<=N-B:
        #Aが1に到達するまで+AとBの距離が2の倍数になるまで
        x=A-1+1
        #Aは負け続け、Bは勝ち続ける
        y=(B-A)//2
        print(x+y)
        
    else:
        #BがNに到達するまで+AとBの距離が2の倍数になるまで
        x=N-B+1
        #Aは勝ち続け、Bは負け続ける
        y=(B-A)//2
        print(x+y)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll sum=0;
	rep(i,n) sum+=a.at(i);
	if(sum%(n*(n+1)/2)!=0){
		cout << "NO" << endl;
		return 0;
	}
	ll k=sum/(n*(n+1)/2);
	vector<ll> b(n);
	rep(i,n-1) b.at(i)=a.at(i+1)-a.at(i);
	b.at(n-1)=a.at(0)-a.at(n-1);
	rep(i,n){
		if(b.at(i)>k || (k-b.at(i))%n!=0){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second



int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    cin >> n ;
    ll a[n];
    rep(i,n) 
    {
          cin >> a[i];
          if(a[i]==0) f=1;
    }
    if(f) 
    {
          cout << 0 ;
          return 0 ;
    }
    
    ans=1;m=1e18;
    f=0;
    k=1e9;
    rep(i,n)
    {
          if(ans>m||ans<0) break;
          if(ans>k&&a[i]>k)
          {
                f=1;
                break;
          }
          
          ans*=a[i];
         //cout << ans << endl ;
    }
    if(ans>m||ans<0||f) cout << -1 ;
    else cout << ans ;
    return 0;
}


Measured memory_bytes: 4416
#include <stdio.h>

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if ((a == 1) || (b == 1) || (c == 1)) {
    puts("NO");
    return 0;
  }    
  
  if (a*b*c == 175) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
  {
    cout<<'1'<<endl;
  }else if(b==0)
  {
    cout<<'2'<<endl;
  }else if(c==0)
  {
    cout<<'3'<<endl;
  }else if(d==0)
  {
    cout<<'4'<<endl;
  }else
  {
    cout<<'5'<<endl;
  }
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n,k;
	int res = 0;

	cin >> n;
	cin >> k;

	for (int i = 0; i < n; ++i)
	{
		int tmp;
		cin >> tmp;
		res += min(tmp,k-tmp);
		//cout << res << endl;
	}

	cout << res*2 << endl;


	return 0;
}

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

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

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

	int N;
	cin >> N;
	int a[3 * N];
	rep(i, 0, 3 * N) cin >> a[i];

	priority_queue<int> left_q;
	priority_queue<int> right_q;


	ll left_sum[N + 1], right_sum[N + 1];
	memset(left_sum, 0, sizeof(left_sum));
	memset(right_sum, 0, sizeof(right_sum));
	rep(i, 0, N) {
		left_q.push(-a[i]);
		left_sum[0] += a[i];
		right_q.push(a[3 * N - i - 1]);
		right_sum[0] += a[3 * N - i - 1];
	}

	
	rep(i, N, 2 * N) {
		left_q.push(-a[i]);
		ll tmp_l = left_q.top();
		left_q.pop();
		left_sum[i - N + 1] = left_sum[i - N] + tmp_l + a[i];
		right_q.push(a[3 * N - i - 1]);
		ll tmp_r = right_q.top();
		right_q.pop();
		right_sum[i - N + 1] = right_sum[i - N] - tmp_r + a[3 * N - i - 1];
	}

	ll ans = left_sum[0] - right_sum[N];
	rep(i, 0, N + 1) {
		ans = max(ans, left_sum[i] - right_sum[N - i]);
	}
	cout << ans << endl;





}


Measured memory_bytes: 3964
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
const int inf=1<<29;
const int maxn=1e5+10;
const int maxm=2e5+10;
int n,m,cnt;
int head[maxn];
struct Edge
{
    int v,c,nx;
}edge[maxm<<1];
struct Node
{
    int v,w;
    bool operator <(const Node&n1) const {
        return w==n1.w?v<n1.v:w<n1.w;
    }
};
int dis[maxn];
bool vis[maxn];
set<int> col[maxn];

void _init() {
    cnt=0;
    memset(head,-1,sizeof(head));
}

inline void add(int u,int v,int c) {
    edge[cnt].v=v; edge[cnt].c=c;
    edge[cnt].nx=head[u];
    head[u]=cnt++;
    edge[cnt].v=u; edge[cnt].c=c;
    edge[cnt].nx=head[v];
    head[v]=cnt++;
}

void bfs() {
    memset(vis,0,sizeof(vis));
    for (int i=1;i<=n;i++) col[i].clear();
    for (int i=1;i<=n;i++) dis[i]=inf;
    dis[1]=0;
    priority_queue<Node> q;
    q.push(Node{1,0});
    while (!q.empty()) {
        Node t=q.top(); q.pop();
        int u=t.v;
        if (vis[u]) continue;
        vis[u]=1;
        for (int i=head[u];i!=-1;i=edge[i].nx) {
            int v=edge[i].v;
            int w=col[u].count(edge[i].c)?0:1;
            if (dis[v]>dis[u]+w) {
                dis[v]=dis[u]+w;
                col[v].clear();
                col[v].insert(edge[i].c);
                q.push(Node{v,-dis[v]});
            } else if (dis[v]==dis[u]+w) {
                col[v].insert(edge[i].c);
            }
        }
    }
}

int main() {
    while (~scanf("%d%d",&n,&m)) {
        _init();
        int u,v,c;
        for (int i=1;i<=m;i++) {
            scanf("%d%d%d",&u,&v,&c);
            add(u,v,c);
        }
        bfs();
        printf("%d\n", dis[n]==inf?-1:dis[n]);
    }
    return 0;
}


Measured memory_bytes: 20216
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0 ; i < n ; i++ ){
            p[i] = sc.nextInt();
            if(p[i] - 1 != i){
                p[i] = -1;
            }
        }
        if(n < 3){
            System.out.println("YES");
        }else{
            Arrays.sort(p);
            if(p[2] == -1){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }
        sc.close();

    }
}

Measured memory_bytes: 35692
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 36
typedef struct{
	char str;
	int num;
}Card;
void bubble(Card*,int);
void sel(Card*,int);
void isStable(Card*,Card*,int);
int main(){
	int n,i,j;
	Card array[N],p[N],q[N];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf(" %c%d",&array[i].str,&array[i].num);
		p[i].str = q[i].str = array[i].str;
		p[i].num = q[i].num = array[i].num;
	}
	bubble(&p,n);
	//for(i=0;i<n;i++) printf("%c%d ",p[i].str,p[i].num);
	i=0;
	while(i<n){
		if(i == n-1){
			printf("%c%d\n",p[i].str,p[i].num);
			break;	
		}
	printf("%c%d ",p[i].str,p[i].num);
	i++;
	}
	printf("Stable\n");
	sel(&q,n);
  	//for(i=0;i<n;i++) printf("%c%d ",q[i].str,q[i].num);
  	i=0;
  	while(i<n){
  		if(i == n-1){
  			printf("%c%d\n",q[i].str,q[i].num);
  			break;	
  		}
  	printf("%c%d ",q[i].str,q[i].num);
  	i++;
  	}
  	isStable(&q,&p,n);
	return 0;
}
void bubble(Card array[],int n){
	int i,j;
	Card p;
	for(i = 0; i < n-1 ; i++){
    for(j = n-1; j > i ; j --){
      if(array[j-1].num > array[j].num){
        p = array[j];
        array[j] = array[j-1];
        array[j-1] = p;
       }
    }
  }
}
void sel(Card array[],int n){
	int lowkey,lowest,i,j;
	Card t;
	for(i=0;i<n;i++){
    lowkey = array[i].num;
    lowest = i;
    for(j=i+1;j<n;j++){
      if(lowkey > array[j].num){
        lowkey = array[j].num;
        lowest = j;
      }
    }
    t = array[i];
   	array[i] = array[lowest];
    array[lowest] = t;
  }
}
void isStable(Card q[],Card p[],int n){
	int i,j,judge=0;
	for(i=0;i<n-1;i++){
		if(q[i].str != p[i].str)judge=1;
	}
	if(judge == 1) printf("Not stable\n");
	else printf("Stable\n");
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define file "gemo"
using namespace std;
typedef long long ll;
const int mod=1000000007;
int read(){
	char c=getchar();
	int x=0;
	while(c<'0' || c>'9')
		c=getchar();
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x;
}
int a[15][15];
ll dp[1<<15][16],pw[2333];
int to[16][1<<15],qwq[1<<15];
int main(){
	//freopen(file".in","r",stdin);
	//freopen(file".out","w",stdout);
	int n=read(),m=read();
	pw[0]=1;
	for(int i=1;i<=m;i++)
		pw[i]=pw[i-1]*2%mod;
	for(int i=1;i<=m;i++){
		int u=read()-1,v=read()-1;
		a[u][v]=1;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<(1<<n);j++){
			if (j>>i&1)
				continue;
			for(int k=0;k<n;k++)
				if (j>>k&1)
					to[i][j]+=a[i][k];
			//fprintf(stderr,"to[%d][%d]=%d\n",i,j,to[i][j]);
		}
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<n;j++)
			if (!(i>>j&1))
				qwq[i]+=to[j][i];
	dp[0][0]=1;
	for(int i=0;i<(1<<n);i++){
		int s=(1<<n)-1-i;
		if ((i&1)!=(i>>1&1))
			continue;
		//fprintf(stderr,"i=%d\n",i);
		bool flag=true;
		for(int j=0;j<n;j++)
			if (dp[i][j])
				flag=false;
		if (flag)
			continue;
		for(int j=s;j;j=(j-1)&s){ //i->j ~to->j
			if ((j&1)!=(j>>1&1))
				continue;
			ll ans=1;
			int sm=0;
			int v=i|j;
			for(int o=0;o<n;o++)
				if (!(v>>o&1))
					ans=ans*((1<<to[o][j])-1)%mod,sm+=to[o][j];
			ans=ans*pw[qwq[j]-sm]%mod;
			if (!ans)
				continue;
			for(int o=0;o<n;o++){
				//fprintf(stderr,"dp[%d][%d]=%lld\n",i,o,dp[i][o]);
				dp[v][o+1]=(dp[v][o+1]+dp[i][o]*ans)%mod;
			}
		}
	}
	ll ans=0;
	for(int i=0;i<=n;i++)
		ans=(ans+dp[(1<<n)-1][i])%mod;
	printf("%lld",((pw[m]-ans)%mod+mod)%mod);
	//fprintf(stderr,"%.5f",(double)clock()/CLOCKS_PER_SEC);
}

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

using namespace std;

int main()
{
    int n , k;cin>>n>>k;int arr[n];
    for(int i = 0 ; i < n ; i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int ans=0;
    for(int i = 0  ; i <  k ; i++)
    {
        ans+=arr[i];
    }cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int N;cin>>N;
  int d[N+10];
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  sort(d,d+N);
  cout<<d[N/2]-d[(N/2)-1]<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main(int argc, char* argv[]) {
	int n;
	cin >> n;

	vector <int> sticks;
	for (int i = 0; i < n; i ++) {
		int tmp;
		cin >> tmp;
		sticks.push_back(tmp);
	}
	sort(sticks.begin(),sticks.end());


	int cnt = 0;
	for (int left = n - 1; left >= 2; left --) {
		for (int right = 0; right < left - 1; right ++) {
			for (int mid = right + 1; mid < left; mid ++) {
				if (sticks[mid] + sticks[right] > sticks[left])
					cnt ++;
			}
		}
	}
	cout << cnt << '\n';
	return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans = -1e18 + 10;
  chmax(ans, a * c);
  chmax(ans, a * d);
  chmax(ans, b * c);
  chmax(ans, b * d);

  cout << ans << endl;

  return 0;
}


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

using LL = long long;
const LL M = 1e9 + 7;

LL power(LL m, LL n) {
  if(!n) return 1;
  if(n & 1) return power(m, n - 1) * m % M;
  return power(m * m % M, n >> 1);
}
LL inverse(const LL x) {
  return power(x, M - 2);
}
LL factorial(const LL n) {
  static vector<LL> memo = {1};
  while(memo.size() <= n) memo.push_back(memo.back() * memo.size() % M);
  return memo[n];
}
LL combination(const LL n, const LL r) {
  return (factorial(n) * inverse(factorial(n - r)) % M) * inverse(factorial(r)) % M;
}

LL d(auto sy, auto sx, auto gy, auto gx) {
  auto dy = gy - sy;
  auto dx = gx - sx;
  return combination(dy + dx, dy);
}

int main() {
  LL H, W, A, B;
  cin >> H >> W >> A >> B;
  LL r = 0;
  for(auto j = B; j < W; ++j) {
    auto i = H-A-1;
    r += d(0, 0, i, j) * d(i+1, j, H-1, W-1) % M;
    r %= M;
  }
  cout << r << endl;
}


Measured memory_bytes: 2420
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

N,K = list(map(int, stdin.readline().rstrip().split()))
ans = 0
d = {}
for kk in range(K):
	dd = int(input())
	l = list(map(int, stdin.readline().rstrip().split()))
	for i in l:
		d[i] = 1
for i in range(1,N+1):
	if(i not in d):
		ans += 1
# print('d:',d)
print(ans)



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

int main()
{
	long long a, b; cin >> a >> b;
	long long ans;
	
	if (a == 1) {
		ans = b;
	}
	else if (b == 1) {
		ans = a;
	}
	else {
		for (long long i = 2; i <= b; i++) {

			if ((a*i) % b == 0) {
				ans = a*i;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
 
  int n;
  scanf("%d",&n);
  int a[n],i;
  for(i=0;i<n;++i)
       scanf("%d",&a[i]);
  
  sort(a,a+n);
  
  float sum=(float)(a[0]+a[1])/2;
  for(i=2;i<n;++i)
  {
      sum=(float)(sum+a[i])/2;
  }
  
  printf("%f",sum);
  
}

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

using namespace std;

void Solution()
{
    int N = 105000; // to judge if the number is prime number
    int ans[10000];
    
    bool data[N];
    
    for(int i = 0;i < N; i++)
    {
        if(i % 2 == 0) // remove the numbers which can be devide by 2
        {
            data[i] = false;
        }
        else
        {
            data[i] = true;
        }
    }
    
    data[1] = false; //remove 1
    data[2] = true; // casue 2 is prime number
    
    for(int i = 3; i < N; i += 2) // remove 3, 5, 7's multiples
    {
        if(data[i])
        {
            for(int j = i + i; j < N; j += i) //remove 3, 5, 7's multiples
            {
                data[j] = false;
            }
        }
    }
    
    
    for(int i = 0, j = 0; i < N; i++)
    {
        if(data[i])
        {
            ans[j++] = i; //check the loop and save the prime number to array
            
            if(j == 10000)
            {
                break;
            }
        }
    }
    
    while(1)
    {
        int n;
        
        cin>>n;
        
        if(n == 0)
        {
            break; //out of loop
        }
        
        long sum = 0;
        
        for(int i = 0; i < n; i++)
        {
            sum += ans[i];
        }
        
        cout<<sum<<endl;
    }
}

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

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

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << 'A' << s2[0] << 'C' << endl;
}


Measured memory_bytes: 256
from collections import deque
S = input()
SS = deque()
for s in S:
    SS.append(s)
Q = int(input())
Que = [list(input().split()) for _ in range(Q)]
r = 0

for q in Que:
    if q[0] == '1':
        r += 1
    else:
        if (q[1] == '1' and r % 2 == 1) or (q[1] == '2' and r % 2 == 0):
            SS.append(q[2])
        else:
            SS.appendleft(q[2])
if r % 2 == 0:
   while len(SS) > 0:
        s = SS.popleft()
        print(s, end='')    
else:
    while len(SS) > 0:
        s = SS.pop()
        print(s, end='')
print('')


Measured memory_bytes: 34416
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int A, B;
	cin >> A;
	cin >> B;
	if ((B-1)%(A-1)==0)
	{
		cout << (B - 1) / (A - 1) << endl;
	}
	else
	{
		cout << (B - 1) / (A - 1)+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256