akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scanf("%d %d %d", &n, &a, &b)
	if a == 0 {
		fmt.Print("0")
		return
	}
	d := n / (a + b)
	e := n % (a + b)
	f := e
	if e > a {
		f = a
	}
	ans := a*d + f
	fmt.Printf("%d", ans)
}


Measured memory_bytes: 512
'use strict'

function main(input) {

  const rate = Number(input);
  let ans = '';

  if (rate < 1200) {
    ans = 'ABC';
  } else if (rate < 2800) {
    ans = 'ARC';
  } else {
    ans = 'AGC';
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

const int NMAX = 8;
bool g[NMAX][NMAX];

int dfs(int v, int N, bool visited[NMAX]) {
    bool all_visited = true;

    rep(i, 0, N) if (!visited[i]) all_visited = false;
    if (all_visited) return 1;

    int ret = 0;
    rep(i, 0, N) {
        if (g[v][i] == false) continue;
        if (visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        g[a-1][b-1] = g[b-1][a-1] = true;
    }

    bool visited[NMAX];
    memset(visited, false, sizeof(visited));
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s,s2;
    cin >> s;
    vector<bool> flag(3,false);
    int c;
    if(s.at(0)=='A'){
        flag.at(0) =true;
    }
    int k=0;
    for(int i=0;i<s.size()-3;i++){
        if(s.at(i+2)=='C' && k==0){
            k++;
            flag.at(1)=true;
            c = i+2;
        }else if(s.at(i+2)=='C' && k>=1){
            flag.at(1)=false;
        }
    }
    s2 =s ;
    flag.at(2)=true;
    transform(s2.begin(),s2.end(),s2.begin(),::tolower);
    for (int i=0;i<s.size();i++){
        if(i!=0 && i!=c){
            if(s.at(i)!=s2.at(i)){
                flag.at(2)=false;
            }
        }
    }
    if(flag.at(0)==true &&flag.at(1)==true &&flag.at(2)==true ){
        cout << "AC"<<endl;
    }else{
        cout <<"WA" <<endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	long long n, k;
	scanf("%lld %lld", &n, &k);
	printf("%lld\n", k%2 ? (n/k)*(n/k)*(n/k) :((n/k)*(n/k)*(n/k) + ((n + (k >> 1))/k)*((n + (k >> 1))/k)*((n + (k >> 1))/k)));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long mod = 1000000007; 
	long long sum = 0; 
	long long sq = 0; 
	long long A[200010] = {};
	int N; cin >> N;  
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
		sum += A[i]; 
		sum %= mod; 
		sq += A[i] * A[i] % mod; 
		sq %= mod; 
	}
	long long ans = mod + sum * sum % mod - sq; 	
	cout << ans * 500000004 % mod << "\n"; 
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n;
vector<int > a;

signed main() {
    cin >> n;
    int t;
    for (int i=0;i<n;i++) {
        cin >> t;
        a.push_back(t);
    }
    int ans;
    ans = *max_element(a.begin(),a.end()) - *min_element(a.begin(), a.end());
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 999769

int hantei(char c){
  if(c == 'A')return 1;
  else if(c == 'C')return 2;
  else if(c == 'G')return 3;
  else if(c == 'T')return 4;
  else return 0;
}

int main(){
  int i,j,k,n,sum,h,p=1;
  int h1,h2;
  char command[7],str[1000000][13],key[13];
  for(i=0;i<M;i++)str[i][0]='\0';
  scanf("%d",&n);
  if(n>1000000) exit(2);
  for(i=0;i<n;i++){
    sum=0;
    p=1;
    scanf("%s %s",command,key);
    for(j=0;j<strlen(key);j++){
      sum+=p*(hantei(key[j]));
      p *= 5;
    }
    
    if(command[0] == 'i'){
      for(k=0;;k++){
	h1=sum%M;
	h2=1+(sum%(M-1));
	h=(h1+k*h2)%M;
	if(strcmp(str[h],key) == 0)break;
	else if(strlen(str[h]) == 0){
	  strcpy(str[h],key);
	  break;
	}
      }
    }else{
      for(k=0;;k++){
	h1=sum%M;
	h2=1+(sum%(M-1));
	h=(h1+k*h2)%M;
	if(strcmp(str[h],key) == 0){
	  printf("yes\n");
	  break;
	}
	else if(strlen(str[h]) == 0){
	  printf("no\n");
	  break;
	}
      }
    }
  } 
  return 0;
}





Measured memory_bytes: 14528
#include <iostream>

using namespace std;

int main(){
 
  int N,X;
  cin >> N >> X;
  int L;
  int count = 1;
  int sum = 0;
  for(int i = 0; i < N; ++i){
    cin >> L;
    sum += L;
    if(sum <= X) count++;
    else break;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

// queue
void solve() {
    ll k; cin >> k;
    queue<ll> que;
    Rep(i, 1, 9) que.push(i);
    ll frnt;
    rep(i, 0, k){
        frnt = que.front(); que.pop();
        if(frnt%10 != 0) que.push(frnt*10 + (frnt%10) - 1);
        que.push(frnt*10 +(frnt%10));
        if(frnt%10 != 9) que.push(frnt*10 + (frnt%10) + 1);
    }
    cout << frnt << "\n";
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makei(A);
	makei(B);
	say(max(A + B, max(A - B, A*B)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    int n;
    cin >> n;
    int ans = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) ans -= ans / i;
        while (n % i == 0) {
            n /= i;
        }
    }
    if (n > 1) ans -= ans / n;
    cout << ans << "\n";
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k; cin>>n>>k;
  unordered_map<char,int> mp; cin>>mp['s']>>mp['p']>>mp['r'];
  string t; cin>>t;
  int res=0;
  for(int i=0; i<k; ++i){
    bool s=true;
    for(int j=i; j<n; j+=k)
      res+=(s==true? mp[t[j]]:0),s=((s==true)&&(t[j+k]==t[j])? false:true);
  }
  cout<<res;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a, b, c;
  a = N / 100;
  b = (N-a*100)/10;
  c = N % 10;
  if (a == 7 || b == 7 || c == 7)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

static int32_t count_one(uint32_t flags)
{
	int32_t one = 0;
	for (int32_t j = 0; j < 10; j++) {
		if (flags & (1 << j))
			one++;
	}
	return one;
}

int main()
{
	int32_t N;
	cin >> N;

	vector<uint32_t> times(N);
	vector<vector<int32_t>> values(N);
	for (int32_t i = 0; i < N; i++) {
		times[i] = 0;
		for (int32_t j = 0; j < 10; j++) {
			int32_t _open;
			cin >> _open;
			times[i] |= _open == 1 ? (1 << j) : 0;
		}
	}
	for (int32_t i = 0; i < N; i++) {
		values[i].resize(11);
		for (int32_t j = 0; j < 11; j++) {
			cin >> values[i][j];
		}
	}

	int64_t res = numeric_limits<int64_t>::min();
	for (uint32_t plan = 0; plan < 1024; plan++) {
		int64_t sum = 0, total_one = 0;
		for (int32_t i = 0; i < N; i++) {
			int32_t one = count_one(plan & times[i]);
			sum += values[i][one];
			total_one += one;
		}
		if (total_one == 0)
			continue;
		res = max(res, sum);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b;
    cin >> n >> a >> b;
    
    string str;
    cin >> str;
    
    int pass = 0;
    int rank = 1;
    
    for(int i = 0;i < n;i++){
        char c = str[i];
        
        if(c == 'a'){
            if(pass < a + b){
                cout << "Yes" << endl;
                pass++;
            }else{
                cout << "No" << endl;
            }
        }
        
        if(c == 'b'){
            if(pass < a + b && rank <= b){
                cout << "Yes" << endl;
                pass++;
                rank++;
            }else{
                cout << "No" << endl;
            }
        }
        
        if(c == 'c'){
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3720
'use strict';
function main(input) {
  const args = input.split('\n'),
        N = parseInt(args[0]),
        A = args[1].split(' ');
  let order = new Array(N);
  for (let i = 0; i < N; ++i) {
    order[parseInt(A[i])-1] = i+1;
  }
  let answer = '';
  for (let i = 0; i < N; ++i) {
    if (i < N-1) {
      answer += order[i] + ' ';
    } else {
      answer += order[i];
    }
  }
  console.log(answer);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32984
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, ans = 0, ptr;
	scanf("%d", &N);
	char S[N];
	for (int i = 0; i < N; ++i) scanf(" %c", &S[i]);
	for (char i = '0'; i <= '9'; ++i) {
		for (char j = '0'; j <= '9'; ++j) {
			for (char k = '0'; k <= '9'; ++k) {
				for (ptr = 0; ptr < N && S[ptr] != i; ++ptr);
				for (++ptr; ptr < N && S[ptr] != j; ++ptr);
				for (++ptr; ptr < N && S[ptr] != k; ++ptr);
				if (ptr < N) ++ans;
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
template <class Key, class Compare = less<Key>>
using Tree = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;




int R, C;
int grid[402][402];
bool visited[402][402];
ll num0, num1;

int dr[4] = {-1, 0, 1, 0};
int dc[4] = {0, 1, 0, -1};

void dfs(int r, int c) {
  visited[r][c] = 1;
  if (grid[r][c] == 0) ++num0; else ++num1;
  for (int d = 0; d < 4; ++d) {
    int r1 = r + dr[d], c1 = c + dc[d];
    if (r1 >= 0 && r1 < R && c1 >= 0 && c1 < C && visited[r1][c1] == 0 && grid[r1][c1] != grid[r][c]) {
      dfs(r1, c1);
    }
  }
}

void Main() {
  cin >> R >> C;
  for (int r = 0; r < R; ++r) {
    string s;
    cin >> s;
    for (int c = 0; c < C; ++c) {
      grid[r][c] = s[c] == '#';
    }
  }
  memset(visited, 0, sizeof(visited));
  ll ans = 0;
  for (int r = 0; r < R; ++r) {
    for (int c = 0; c < C; ++c) {
      if (visited[r][c] == 0) {
        num0 = num1 = 0;
        dfs(r, c);
        ans += num0 * num1;
      }
    }
  }
  cout << ans << '\n';
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	inputs := scanIntNums()
	check(inputs)
}

// example
func check(nums []int) {
	var sum int
	for _, num := range nums {
		sum += num
	}
	if sum > 21 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}

}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main(){
  int a[5],k;
  for(int i = 0;i < 5;i++)cin >> a[i];
  cin >> k;
  if(a[4] - a[0] > k)cout << ":(";
  else cout << "Yay!";
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {

            while (true) {
                char c;
                int[] dice = {1,2,6,5,4,3};
                int sum=dice[0];
                int n = Integer.parseInt(br.readLine());
                if(n==0){
                    break;
                }
                for (int i = 0; i < n; i++) {
                    c = br.readLine().charAt(0);
                    switch (c) {
                        case 'N':
                            dice = n(dice);
                            break;
                        case 'E':
                            dice = e(dice);
                            break;
                        case 'W':
                            dice = w(dice);
                            break;
                        case 'S':
                            dice = s(dice);
                            break;
                        case 'R':
                            dice = r(dice);
                            break;
                        case 'L':
                            dice = l(dice);
                            break;
                    }
                    sum += dice[0];
                }
                System.out.println(sum);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    static int[] n(int[] dice){
        int[] ret = dice.clone();
        ret[0] = dice[1];
        ret[1] = dice[2];
        ret[2] = dice[3];
        ret[3] = dice[0];
        return ret;
    }

    static int[] e(int[] dice){
        int[] ret = dice.clone();
        ret[0] = dice[4];
        ret[5] = dice[0];
        ret[2] = dice[5];
        ret[4] = dice[2];
        return ret;
    }

    static int[] w(int[] dice){
        int[] ret = dice.clone();
        ret[0] = dice[5];
        ret[5] = dice[2];
        ret[2] = dice[4];
        ret[4] = dice[0];
        return ret;
    }

    static int[] s(int[] dice){
        int[] ret = dice.clone();
        ret[0] = dice[3];
        ret[1] = dice[0];
        ret[2] = dice[1];
        ret[3] = dice[2];
        return ret;
    }

    static int[] r(int[] dice){
        int[] ret = dice.clone();
        ret[1] = dice[5];
        ret[4] = dice[1];
        ret[3] = dice[4];
        ret[5] = dice[3];
        return ret;
    }

    static int[] l(int[] dice){
        int[] ret = dice.clone();
        ret[1] = dice[4];
        ret[4] = dice[3];
        ret[3] = dice[5];
        ret[5] = dice[1];
        return ret;
    }
}

Measured memory_bytes: 24668
import sys

def main():
    MOD = 998244353
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,S = LI()
    A = LI()
    dp = [0] * (S+1)
    ans = 0
    for i in range(N):
        dp[0] = i+1
        for j in range(S,0,-1):
            if A[i] > j: break
            dp[j] = (dp[j] + dp[j-A[i]]) % MOD
        ans = (ans + dp[-1] * (N-i)) % MOD
        dp[-1] = 0
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int y,m,d,i;
	string s;
	cin >> s;
	for(i=0; i<10; ++i){
		s[i] -= '0';
	}
	y = s[0]*1000+s[1]*100+s[2]*10+s[3];
	m = s[5]*10+s[6];
	d = s[8]*10+s[9];
	if(y>2019){
		cout << "TBD" << endl;
	}else if(y<2019){
		cout << "Heisei" << endl;
	}else if(m>4){
		cout << "TBD" << endl;
	}else if(m<4){
		cout << "Heisei" << endl;
	}else if(d>30){
		cout << "TBD" << endl;
	}else{
		cout << "Heisei" << endl;
	}
	return 0;
}


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

int n;
int pre;
int x;

int main(){
	scanf("%d",&n);
	scanf("%d",&pre);
	pre--;
	bool ans=1;
	for(register int i=1;i<n;i++){
		scanf("%d",&x);
		if(x<pre){
			ans=0;
			break;
		}
		if(x!=pre)
			pre=x-1;
	}
	if(ans)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
class diceClass:
    label = []
    def __init__(self,l):
        if len(l) == 6:
            self.label = l
    def move(self,c):
        if c.upper() == 'N':
            buf = []
            buf.append(self.label[1])
            buf.append(self.label[5])
            buf.append(self.label[2])
            buf.append(self.label[3])
            buf.append(self.label[0])
            buf.append(self.label[4])
            self.label = buf
        elif c.upper() == 'E':
            buf = []
            buf.append(self.label[3])
            buf.append(self.label[1])
            buf.append(self.label[0])
            buf.append(self.label[5])
            buf.append(self.label[4])
            buf.append(self.label[2])
            self.label = buf
        elif c.upper() == 'W':
            buf = []
            buf.append(self.label[2])
            buf.append(self.label[1])
            buf.append(self.label[5])
            buf.append(self.label[0])
            buf.append(self.label[4])
            buf.append(self.label[3])
            self.label = buf
        elif c.upper() == 'S':
            buf = []
            buf.append(self.label[4])
            buf.append(self.label[0])
            buf.append(self.label[2])
            buf.append(self.label[3])
            buf.append(self.label[5])
            buf.append(self.label[1])
            self.label = buf
    def get_label(self):
        return self.label[0]
in_line = raw_input().split()
dice = diceClass(in_line)
move = raw_input()
for c in move:
    dice.move(c)
print dice.get_label()

Measured memory_bytes: 6484
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <bitset>

using namespace std;
typedef long long LL;
const int maxn = 20;
const int mod = 1e9+7;

int c[maxn][1<<15],_[maxn][1<<15];
int n,m,dp[1<<15],S;

int fpm(LL p,int k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
int main()
{
	#ifdef Amberframe
		freopen("agc016f.in","r",stdin);
		freopen("agc016f.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);S=(1<<n)-1;
	for (int u,v,i=1;i<=m;i++)
		scanf("%d %d",&u,&v),u--,v--,
		c[u][1<<v]++,_[v][1<<u]++;
	for (int i=0;i<n;i++)
	for (int j=1;j<=S;j++) {
		int o=j&-j;
		c[i][j]=c[i][j^o]+c[i][o];
		_[i][j]=_[i][j^o]+_[i][o];
	}
	
	for (int i=1;i<=S;i++)
	if ((i&1)==(i>>1&1)) {
		int res=1;
		for (int j=i-1&i;j;j=j-1&i)
		if (int w=dp[j]) {
			for (int k=0;k<n;k++)
			if (j>>k&1) {
				w=(LL)w*(1ll<<_[k][j^i])%mod;
				w=(LL)w*((1ll<<c[k][j^i])-1)%mod;
			}
			res=(res+w)%mod;
		}
		dp[i]=res;
	}
	int ans=(fpm(2,m)-dp[S])%mod;
	printf("%d",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 4864
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,c = li()
x_cw = []
v_cw = []
x_ccw = []
for _ in range(n):
    x,v = li()
    x_cw.append(x)
    v_cw.append(v)
    x_ccw.append(c-x)
    
x_ccw = [0] + sorted(x_ccw)
v_ccw = [0] + v_cw[::-1]
x_cw = [0] + x_cw
v_cw = [0] + v_cw
    
for i in range(1,n+1):
    v_cw[i] += (v_cw[i-1] - (x_cw[i]-x_cw[i-1]))
    v_ccw[i] += (v_ccw[i-1] - (x_ccw[i]-x_ccw[i-1]))
    
    
max_cw = [0]
max_ccw = [0]
mx_cw = [0]
mx_ccw = [0]
for i in range(1,n+1):
    max_cw.append(max(max_cw[-1], v_cw[i]))
    max_ccw.append(max(max_ccw[-1], v_ccw[i]))
    
    if max_cw[-1] != max_cw[-2]:
        mx_cw.append(x_cw[i])
    else:
        mx_cw.append(mx_cw[-1])

    if max_ccw[-1] != max_ccw[-2]:
        mx_ccw.append(x_ccw[i])
    else:
        mx_ccw.append(mx_ccw[-1])

ans = 0
for i in range(n+1):
    temp = max_cw[i] + max_ccw[n-i] - min(mx_cw[i], mx_ccw[n-i])
    ans = max(temp, ans)

        
print(ans)


Measured memory_bytes: 30832
#include<iostream>
#include<math.h>
using namespace std;

// 9C4

//指定された桁の値を返す手続きを定義する
/* 123の2けた、123 = 123 % 100 - 123 % 10 
                   = 23 - 3
				   = 20
   123の１けた、123 = 123 % 10 - 123 % 1
                    = 3 - 0
					= 3 */
int girder_number(int keta,int n)
{
	return (keta % int(pow(10,n)) - keta % int(pow(10,n-1))) / pow(10,n-1);
}
	
int* make_list_n_4(int n)
{
	int num[4];
	// sは桁数、この場合は4桁なのでs=4-1=3
	int s = 4-1;
	for (int i=0;i<=s;i++){
		num[i]=girder_number(n,i+1);
		// cout << "make_list_n_4[" << i << "]=" << num[i] << endl;
	}
	return num;
}

int how_much_plus_pair(int n)
{
	int a=0;
	int i=0;
	int ans = 0;
	if (n == 0)
		return 1;
	else if(n > 36)
		return 0;
	else {
		for(int i=0;i<=9999;i++)
		{
			ans = 0;
			for (int k=0;k<=3;k++)
				ans += make_list_n_4(i)[k];
			if (n == ans)
				a++;
		}
	return a;
	}
}

int main()
{
	/* for (int i=0;i<=3;i++)
		cout << make_list_n_4(1234)[i] << "," ;*/
	int n;
	while(cin >> n){
		// cout << "make_list_n_4(n)=" << make_list_n_4(n) << endl;
		int testaa[] = {1,2,3,4};
		int ans = 0;
		cout << how_much_plus_pair(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10,mod=1e9+7;
struct node {
	int x,y;
	node(int x=0,int y=0): x(x),y(y) {}
	friend bool operator <(node A,node B) { return A.x==B.x?A.y>B.y:A.x>B.x; }
	friend bool operator ==(node A,node B) { return A.x==B.x&&A.y==B.y; }
}a[N];
int xi[N],yi[N],n,m,cnt;
int val[N],tot;

int c[N];
void add(int i,int t) { for(;i<=tot;i+=i&-i) c[i]=(c[i]+t)%mod; }
int query(int i) { int ans=0; for(;i;i-=i&-i) ans=(ans+c[i])%mod; return ans; }
int main() {
	rd(n),rd(m);
	for(int i=1;i<=n;++i) rd(yi[i]);
	for(int i=1;i<=m;++i) rd(xi[i]);
	for(int i=1;i<=n;++i) {
		if(yi[i]<=xi[1]||yi[i]>=xi[m]) continue;
		int r=lower_bound(xi+1,xi+m+1,yi[i])-xi;
		int l=r-1;
		a[++cnt]=node(xi[l]-yi[i],xi[r]-yi[i]);
	}
	sort(a+1,a+cnt+1);
	cnt=unique(a+1,a+cnt+1)-a-1;
	for(int i=1;i<=cnt;++i) val[++tot]=a[i].y;
	sort(val+1,val+tot+1);
	tot=unique(val+1,val+tot+1)-val-1;	
	for(int i=1;i<=cnt;++i) a[i].y=lower_bound(val+1,val+tot+1,a[i].y)-val;
	int ans=1;
	for(int i=1;i<=cnt;++i) {
		int t=(query(a[i].y-1)+1)%mod;
		ans=(ans+t)%mod;
		add(a[i].y,t);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


bool f(int x) {
  int keta = 0;
  while(x) {
    keta++;
    x /= 10;
  }
  return keta%2 == 1;
}

int main() {
  int n; cin >> n;
  int ans = 0;
  for (int i =1; i <= n; i++) {
    if (f(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll g = a[0];
  for(int i = 1; i < n; ++i) g = __gcd(g, a[i]);
  int ans = 0;
  while(g%2==0) {
    ++ans;
    g/=2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
//




//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s ;
  cin >> s ;
  int n = SZ(s) ;
  REP(i,n){
    cout << "x" ;
  }
  cout <<endl ;
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    ll ans=0;
    vector<ll> a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    SORT(a);SORT(b);SORT(c);
    vector<ll> bc(n+1,0);
    rep(i,n){
        ll ind=lower_bound(ALL(c),b[i]+1)-c.begin();
        bc[i]=n-ind;
    }
    vector<ll> sumbc(n+2,0);
    for(int i=n-1;i>=0;i--){
        sumbc[i]=sumbc[i+1]+bc[i];
    }
    rep(i,n){
        ll ind=lower_bound(ALL(b),a[i]+1)-b.begin();
        ans+=sumbc[ind];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}
int dp[1001][1001];

int lcs(string x,string y){

  memset(dp,0,sizeof(dp));
  int m,n,ii,jj,maxl;

  m = x.size();
  n = y.size();
  maxl = 0;
  x = ' ' + x;
  y = ' ' + y;
  for(ii=1;ii<=m;ii++){
    for(jj=1;jj<=n;jj++){

      if( x[ii] == y[jj]){
        //cout << "hoge" << endl;

        dp[ii][jj] = dp[ii - 1][jj -1] + 1;

      }
      
      else{

        dp[ii][jj] = max(dp[ii-1][jj],dp[ii][jj-1]);

      }
      maxl = max(maxl,dp[ii][jj]);      
    }
  }
  
  return maxl;

}

int main(){
  
  long ii,jj,kk;
  vector<int> a;

  int q;
  cin >> q;

  string x,y;
  int len;
  
  for(ii=0;ii<q;ii++){
    
    cin >> x >> y;
    len = lcs(x,y);

    cout << len << endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
	int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int m=*max_element(A.begin(),A.end());
  sort(A.begin(),A.end());

  vector<bool>ok(10000000,true);

  for(int i=0;i<N;i++){
    if(A[i]==A[i+1]){ok[A[i]]=false;}
    for(int j=2;j<=(m+A[i]-1)/A[i];j++){
      ok[A[i]*j]=false;
    }
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(ok[A[i]]){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
lli solve(lli num1){
  lli num2 = 1;
  vector<lli>vec(num1+1);
  for(int k=2;k<=num1;k++){
    lli num3=k;
    for(int i=2;i<num1+1;i++){
      while(num3%i==0){
			vec[i]++;
			num3/=i;
      }
    }
  }
  for(int i=2;i<num1+1;i++){	
		num2=(num2*(vec[i]+1))%mod;
	}
	return num2;
}
int main() {
  lli A=1,B,C=INF,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N;
  Out(solve(N));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,d,cnt=0;
	cin >> n >> m >> d;
	for(int i=n;i<=m;i++){
		if(i%d==0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int main(){
	int n;
	scanf("%d", &n);
	
	printf("%d\n", n*n);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int H,A,n;
    scanf("%d %d",&H,&A);
    n=H/A;
    if(H%A==0)
    {
        printf("%d\n",n);
    }
    else
    {
        n=n+1;
        printf("%d\n",n);
    }
    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    string S;
    cin >> S;
    if (n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < n / 2; i++){
        if (S[i] != S[i + n / 2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

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

	int n, m;
	map<string, int> blue, red;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		blue[s]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		string s;
		cin >> s;
		red[s]++;
	}

	int ans = 0;
	for (auto p : blue) {
		ans = max(ans, p.second - red[p.first]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

void show(vector<P> v) {
  REP(i,v.size()) {
    cout << v[i].first << " " << v[i].second << endl;
  }
}

int main() {
  int n,m; cin >> n >> m;
  vector<P> x(n);
  int a,b;
  REP(i,n) { cin >> a >> b; x[i] = {a,b}; }

  sort(x.begin(), x.end());

  ll ans = 0;
  for (int i = 0; i < n && m > 0; i++) {
    int price = x[i].first;
    int num = x[i].second;

    ans += (ll)price * min(num, m);
    m-=num;
  }
  COUT(ans);
  return 0;
}

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

long long Combination(int n, int r) {
  vector<vector<long long>> C(n + 1, vector<long long>(n + 1, 1));
  for (int i = 1; i <= n; i++) for (int j = 1; j < i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
  return C[n][r];
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<long long> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];
  sort(v.begin(), v.end(), greater<long long>());
  double ans1 = 0;
  for (int i = 0; i < A; i++) ans1 += v[i];
  ans1 /= A;
  long long ans2 = 0;
  if (v[0] == v[A - 1]) {
    int n = 0;
    for (int i = 0; i < N; i++) if (v[i] == v[0]) n++;
    for (int r = A; r <= min(n, B); r++) ans2 += Combination(n, r);
  } else {
    int n = 0, r = 0;
    for (int i = 0; i < N; i++) if (v[i] == v[A - 1]) n++;
    for (int i = 0; i < A; i++) if (v[i] == v[A - 1]) r++;
    ans2 = Combination(n, r);
  }
  cout << fixed << ans1 << endl;
  cout << ans2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

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

    int n;
    cin >> n;
    vector<int> dp(n+1, INF);
    dp[0] = 0;
    for (int i = 1; i <= n; ++i) {
        int power = 1;
        while (i - power >= 0) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 6;
        }
        power = 1;
        while (i - power >= 0) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 9;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LL long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 1e6 + 5;

int a[N], b[N];


void solve() {
    int n, m, p;
    scanf("%d %d %d", &n, &m, &p);
    int ans = 0;
    int mi = INF;
    rep(i, 1, n) {
        scanf("%d", &a[i]);
        mi = min(mi, a[i]);
    }
    ans += mi;
    mi = INF;
    rep(i, 1, m) {
        scanf("%d", &b[i]);
        mi = min(mi, b[i]);
    }
    ans += mi;

    rep(i, 1, p) {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        ans = min(ans, a[x] + b[y] - c);
    }
    printf("%d\n", ans);
    return ;
}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 4736
#include <iostream>

using namespace std;
using ll = long long;

template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const int MOD = 1e9+7;

using mint = ModInt<MOD>;

mint dp[10101][101][2];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  string K;
  int D;
  cin >> K >> D;
  int N = K.length();

  // dp[dgt][r][isless] = 上からdgt桁目まで決めたときの総数。islessが1ならKより確定で小さい。rは総和をDで割ったあまり
  REP(i, 10005) REP(j, D) REP(k, 2) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  REP(dgt, N) REP(isless, 2) REP(r, D) {
    int c = K[dgt] - '0';
    REP(d, (isless?9:c)+1) {
      dp[dgt+1][(r+d)%D][isless || (d < c)] += dp[dgt][r][isless];
    }
  }
  cout << dp[N][0][0] + dp[N][0][1] - 1 << "\n";

  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for(int i = 0; i < n;){
       cnt++;
       i++;
       while(s[i] == s[i-1]&&i<n){
            i++;
        }
    } 
    cout << cnt << endl;
    return 0;
}


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

int main()
{
 long long a,b,k;
 cin>>a>>b>>k;
 if(k>=a+b)
 cout<<0<<" "<<0;
 else if(k>=a&&k<a+b)
 cout<<0<<" "<<a+b-k;
 else
 cout<<a-k<<" "<<b;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())

d = int(abs(X)/D)
if X > 0:
    r = X - d*D
    if abs(r-D) < abs(r):
        r = r-D
    min_count = int((X-r)/D)
else:
    r = X + d*D
    if abs(r+D) < abs(r):
        r = r+D
    min_count = int(abs(X-r)/D)

if K < min_count:
    print(int(abs(X)) - K*D)
else:
    if (K - min_count) % 2 == 0:
        print(int(abs(r)))
    else:
        print(int(abs(abs(r)-D)))


Measured memory_bytes: 9140
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int N, k = 0;
		int[] A = new int[100];
		Scanner stdIn = new Scanner(System.in);

		N = stdIn.nextInt();

		for(int i = 0; i < N; i++){
			A[i] = stdIn.nextInt();
		}

		k = bubbleSort(N, A);
		trace(N, A, k);
	}

	public static void trace(int N, int[] A, int k){
		for(int i = 0; i < N; i++){
			if(i > 0)	System.out.print(" ");
			System.out.print(A[i]);
		}
		System.out.println();
		System.out.println(k);
	}

	public static int bubbleSort(int N, int[] A){
		int k = 0;
		for(int i = 0; i < N - 1; i++){
			for(int j = N - 1; j > i; j--){
				if(A[j] < A[j - 1]){
					int tmp = A[j - 1];
					A[j - 1] = A[j];
					A[j] = tmp;
					k++;
				}
			}
		}
		return k;
	}

}

Measured memory_bytes: 26344
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

int root(int[] uf, int u) {
  return (uf[u] < 0) ? u : (uf[u] = uf.root(uf[u]));
}
bool connect(int[] uf, int u, int v) {
  u = uf.root(u);
  v = uf.root(v);
  if (u == v) return false;
  if (uf[u] > uf[v]) swap(u, v);
  uf[u] += uf[v];
  uf[v] = u;
  return true;
}

alias Pt = Tuple!(int, "a", int, "b");

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto P = new Pt[N];
      foreach (i; 0 .. N) {
        P[i].a = readInt();
      }
      foreach (i; 0 .. N) {
        P[i].b = readInt();
      }
      P.sort!((p, q) => ([p.b, p.a] < [q.b, q.a]));
      debug {
        writeln("P = ", P);
      }
      
      auto as = new Tuple!(int, int)[N];
      foreach (i; 0 .. N) {
        as[i] = tuple(P[i].a, i);
      }
      as.sort();
      
      bool ans = true;
      foreach (i; 0 .. N) {
        ans = ans && (as[i][0] <= P[i].b);
      }
      
      auto uf = new int[N];
      uf[] = -1;
      foreach (i; 0 .. N) {
        uf.connect(as[i][1], i);
      }
      if (-uf[uf.root(0)] == N) {
        bool found;
        foreach (i; 0 .. N - 1) {
          found = found || (as[i + 1][0] <= P[i].b);
        }
        debug {
          writeln("found = ", found);
        }
        ans = ans && found;
      }
      
      writeln(ans ? "Yes" : "No");
    }
  } catch (EOFException e) {
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int h,w;
	cin >> h >> w;
	char s[h][w];
	rep(i,h) rep(j,w) cin >> s[i][j];
	rep(i,h){
		rep(j,w){
			if(s[i][j] == '#') cout << '#';
			else{
				int cnt = 0;
				for(int y = -1; y <= 1; y++){
					for(int x = -1; x <= 1; x++){
						if(x == 0 && y == 0) continue;
						int nx = j+x, ny = i+y;
						if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
						if(s[ny][nx] == '#') cnt++;
					}
				}
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = list(map(int, input().split()))
acc = [0] * (n + 1)
for i in range(n):
    acc[i + 1] = acc[i] + a[i]
acc.sort()
# 同じ数の個数をi とすると　sum(iC2) が答え
ans = 0
tmp = 0
num = 0
for i in acc:
    if tmp == i:
        num += 1
    else:
        if num > 1:
            ans += num * (num - 1) // 2
        tmp = i
        num = 1
if num > 1:
    ans += num * (num - 1) // 2
print(ans)


Measured memory_bytes: 30828
#include <iostream>
#include <list>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
  list<int> li;
  int n;
  string answer[2] = {"YES", "NO"};
  int count=0;

  cin >> n;
  for (int i=0; i < n; i++) {
    int num;
    cin >> num;
    li.push_back(num);
    if (num%2!=0) {
      count++;
    }
  }

  cout << answer[count%2] << endl;
  return 0;
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N) {
  long long ans = N / 2;
  if( N % 2 == 0 ) ans--;
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 764