akhauriyash/Code-Regression huggingface dataset:
///====================== TEMPLATE STARTS HERE =====================///
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define pb push_back
#define MP make_pair
#define ff first
#define ss second
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define POPCOUNT __builtin_popcountll
#define Set(N,p) ((N)|((1LL)<<(p)))
#define Reset(N,p) ((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)

#define LL long long
#define LLU long long unsigned int
typedef pair < int, int > pii;
typedef pair < LL, LL > pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pll> vll;

#ifdef s_da_sailor
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif // s_da_sailor

inline LL gcd ( LL a, LL b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}

LL ext_gcd ( LL A, LL B, LL *X, LL *Y ){
    LL x2, y2, x1, y1, x, y, r2, r1, q, r;
    x2 = 1; y2 = 0;
    x1 = 0; y1 = 1;
    for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) {
        q = r2 / r1;
        r = r2 % r1;
        x = x2 - (q * x1);
        y = y2 - (q * y1);
    }
    *X = x2; *Y = y2;
    return r2;
}

inline LL modInv ( LL a, LL m ) {
    LL x, y;
    ext_gcd( a, m, &x, &y );
    x %= m;
    if ( x < 0 ) x += m;
    return x;
}

inline LL bigmod ( LL a, LL p, LL m ) {
    LL res = 1 % m, x = a % m;
    while ( p ) {
        if ( p & 1 ) res = ( res * x ) % m;
        x = ( x * x ) % m; p >>= 1; /// For bigmod2 multiply here using mulmod
    }
    return res;
}


//int knightDir[8][2] = { {-2,1},{-1,2},{1,2},{2,1},{2,-1},{-1,-2},{1,-2},{-2,-1} };
//int dir4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
//int dir8[8][2] = {{-1,0},{0,1},{1,0},{0,-1},{-1,-1},{1,1},{1,-1},{-1,1}};
const LL inf = 2147383647;
const LL mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-11;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); /// For generating random numbers

///======================  TEMPLATE ENDS HERE  =====================///

void solve() {
    LL a, b, n;
    cin >> a >> b >> n;

    LL x = ((b/n)+1), y (((a-1)/n)+1);
    if(a==0) y = 0;

    cout << x-y << "\n";
}

int main () {
    #ifdef s_da_sailor
    freopen ( "input.txt", "r", stdin );
    //freopen ( "output.txt", "w", stdout );
    #endif // s_da_sailor

    fast_cin;

    solve();

    return 0;
}


Measured memory_bytes: 3668
<?php 
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();
$a = $sc->nextInt();
$b = $sc->nextInt();
$c = $a * $b;

if ($c % 2 == 0) {
    out::println('Even');
} else {
    out::println('Odd');
}


Measured memory_bytes: 4984
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int N, M;   cin >> N >> M;
    Graph G(N+1);
    queue<int> que;
    vector<int> ans(N+1,0);
    for(int i=0; i<M; i++){
        int A, B;   cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    ans[1] = 1;
    que.push(1);
    while(!que.empty()){
        int x = que.front();
        que.pop();
        for(int i : G[x]){
            if(ans[i] > 0)  continue;
            ans[i] = x;
            que.push(i);
        }
    }
    for(int i=2; i<N+1; i++) if(ans[i] == 0){print("No"); return 0;}
    print("Yes");
    for(int i=2; i<N+1; i++) print(ans[i]);
}

Measured memory_bytes: 10216
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n,ans=0;
	string s="No";
	bool flag = false;

	cin >> n;

	vecll a(n), count(n, 0);

	forll(i, 0, n)
		cin >> a[i];

	forll(i, 0, n)
	{
		while (a[i] % 2 == 0)
		{
			a[i] /= 2;
			count[i]++;
		}
	}

	forll(i, 0, n)
		ans += count[i];

	cout << ans;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

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

  long long ans = -5e18;
  vector<bool> visit;

  for (int i = 0; i < n; i++) {
    visit.assign(n, false);
    int v = i, len = 0;
    long long sum = 0;

    while (!visit[v]) {
      visit[v] = true;
      v = p[v];
      sum += a[v];
      len++;
    }
    
    int round = max(0, k / len - 1);
    int tail = k - round * len;
    long long best = -5e18, now = 0;

    while (tail--) {
      v = p[v];
      now += a[v];
      best = max(best, now);
    }
    if (sum > 0) best += round * sum;
    ans = max(ans, best);
  }
  
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

int n, a[3 * 100000], a2[3 * 100000];
ll fsum[100001], bsum[100001], ans = INT64_MIN;

int main() {
	cin >> n;
	for (int i = 0; i < 3 * n; i++) {
		cin >> a[i];
		a2[3 * n - (i + 1)] = a[i];
	}

	multiset<int> f;
	multiset<int> b;
	for (int i = 0; i < n; i++) {
		fsum[0] += a[i];
		f.insert(a[i]);

		bsum[n] += a2[i];
		b.insert(a2[i]);
	}

	//cout <<"fsum:" <<  fsum[0] << " bsum:" << bsum[n] << endl;

	for (int i = 0; i < n; i++) {
		if (a[n+i] > *f.begin()) {
			fsum[i+1] = fsum[i]+(a[n+i]-*f.begin());
			f.erase(f.begin());
			f.insert(a[n+i]);
		}
		else {
			fsum[i + 1] = fsum[i];
		}

		auto itr = --b.end();
		if (a2[n+i] < *itr) {
			//cout << "itr:" << *itr << endl;
			bsum[n-(i+1)] = bsum[n-i]+a2[n+i]-*itr;
			b.erase(itr);
			b.insert(a2[n + i]);
		}
		else {
			bsum[n - (i + 1)] = bsum[n - i];
		}

	}
	for (int i = 0; i <= n; i++) {
		ans = max(ans, fsum[i] - bsum[i]);
	}

	cout << ans << endl;

	/*cout << endl;
	for (int i = 0; i <= n; i++) {
		cout << fsum[i] << " ";
	}
	cout << endl;
	cout << endl;
	for (int i = 0; i <= n; i++) {
		cout << bsum[i] << " ";
	}*/
}

Measured memory_bytes: 13568
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)

	a, b := nextInt(sc), nextInt(sc)
	c, d := nextInt(sc), nextInt(sc)

	fmt.Fprintf(out, "%d\n", min(a, b)+min(c, d))
	return nil
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> P(N); cin >> P;
  sort(P.begin(), P.end());
  int sum = 0;
  for (int i = 0; i < N - 1; ++i) sum += P[i];
  sum += P[N-1]/2;
  cout << sum << endl;
}


Measured memory_bytes: 3596
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
testimony = [[] for _ in range(n)]
for i in range(n):
    a = I()
    testimony[i] = LIR(a)


ans = 0
for j in range(2 ** n - 1, -1, -1):
    flag = 0
    bit_cnt = 0
    for k in range(n):
        if j >> k & 1:
            bit_cnt += 1
            for x, y in testimony[k]:
                if y != j >> (x - 1) & 1:
                    flag = 1
                    break
            if flag:
                break
    else:
        ans = max(ans, bit_cnt)


print(ans)

Measured memory_bytes: 45296
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

//#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1e3+5,NN=N*N;

vi v[NN],vis(NN),dist(NN),ind(NN);
int mat[N][N];

int n;

int getnode(int x,int y)
{
    if(x>y)
        swap(x,y);

    return ((x-1)*n+y);
}

void solve()
{
    cin>>n;

    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<n-1;++j)
            cin>>mat[i][j];
    }

    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<n-1;++j)
        {
            int a=getnode(i,mat[i][j-1]);
            int b=getnode(i,mat[i][j]);
            v[a].pb(b);
            ++ind[b];
        }
    }

    queue<int> qu;

    for(int i=1;i<=n;++i)
    {
        for(int j=i;j<=n;++j)
        {
            int x=getnode(i,j);
            if(sz(v[x]) && !ind[x])
                qu.push(x),vis[x]=1;
        }
    }

//    for(int i=1;i<=n*n;++i)
//    {
//        dbug(i);
//        show(v[i]);
//    }

    int ans=0;
    while(!qu.empty())
    {
        auto x=qu.front();
        qu.pop();

        ans=max(ans,dist[x]);

        for(auto c:v[x])
        {
            if(vis[c])
            {
                cout<<-1;
                return;
            }

            --ind[c];
            if(!ind[c])
            {
                qu.push(c);
                vis[c]=1;
                dist[c]=dist[x]+1;
            }
        }
    }

    for(int i=1;i<=n*n;++i)
    {
        if(sz(v[i]) && ind[i])
        {
            //cout<<i<<" "<<ind[i]<<"\n";
            cout<<-1;
            return;
        }
    }

    cout<<ans+1;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N,A;
    cin >> N >> A;

    cout << (N%500<=A ? "Yes" : "No") << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
'use strict'
function main(input) {
  input = input.trim().split('\n')
  let nums = input.shift().split(' ')
  input = input.map(row => {
    row = row.split('');
    return row.map(val => val === '.' ? 0 : val)
  })


  const targets = (i, j) => {
    return [
      [i - 1, j - 1], [i - 1, j], [i - 1, j + 1],
      [i, j - 1], [i, j + 1],
      [i + 1, j - 1], [i + 1, j], [i + 1, j + 1],
    ]
  }

  const add = (i, j) => {
    targets(i, j).forEach(t => {
      if (
        t[0] >= 0 && t[0] < Number(nums[0]) &&
        t[1] >= 0 && t[1] < Number(nums[1]) && 
        input[t[0]][t[1]] !== '#'
      ) { input[t[0]][t[1]]++ }
    })
  }

  for (let i = 0; i < Number(nums[0]); i++) {
    for (let j = 0; j < Number(nums[1]); j++) {
      if (input[i][j] === '#') add(i, j)
    }
  }

  input = input.map(row => row.join('')).join('\n')
  
  console.log(input)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 8844
# coding: utf-8
# Your code here!

d= int(input())

C = list(map(int,input().split()))
CB = [0 for i in range(len(C))]

c = sum(C)

total = 0

#print(c,C,CB)
L = []

for i in range(d):
    L.append(list(map(int,input().split())))

#print(L)

T = []

for i in range(d):
    T.append(int(input()))

#print(T)

def cnt(CB,t):
    for i in range(len(CB)):
        if i != t-1:
            CB[i] += 1
        else:
            CB[i] = 0
    
    return CB

def sumA(C,CB):
    a = 0
    for i in range(len(CB)):
        a += CB[i]*C[i]
    return a

for i in range(len(T)):
    CB = cnt(CB,T[i])
    total += L[i][T[i]-1] - sumA(C,CB)
    print(total)





Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e3 + 10;
const int MOD = 1e9 + 7;
ll dp[N][N][2][2], A[N], B[N], prea[N], preb[N], pos[N];
void add(ll& x, ll y) {
    x += y;
    x %= MOD;
}
int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    for(int i = 1; i <= m; i++) {
        cin >> B[i];
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            for(int a = 0; a < 2; a++) {
                for(int b = 0; b < 2; b++) {
                    ll need = 0, need2 = 0;
                    if(A[i] == B[j]) {
                        need2 = dp[i-1][j-1][0][0] + 1;
                    }
                    if(a==0 && b==0) add(dp[i][j][a][b], dp[i][j-1][1][0]+dp[i-1][j][0][1]+dp[i-1][j-1][0][0]+need2);
                    if(a==1 && b==0) add(dp[i][j][a][b], dp[i][j-1][1][0]+need2);
                    if(a==0 && b==1) add(dp[i][j][a][b], dp[i-1][j][0][1]+need2);
                    if(a==1 && b==1) add(dp[i][j][a][b], need2);
                }
            }
        }
    }
    cout << (1+dp[n][m][0][0])%MOD << '\n';
    return 0;
}

Measured memory_bytes: 125952
As, Bs, Ms = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

bas = min(A) + min(B)

ans = bas
for i in range(Ms):
  a, b, c = map(int, input().split())
  if A[a-1]+B[b-1]-c < ans:
    ans = A[a-1]+B[b-1]-c

print(ans)

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

using namespace std;

const int N = 1e5 + 5;
int a[103], dp[N][2];
int n, k;

int go(int rem, int turn){
	int &ans = dp[rem][turn];
	if(ans != -1)
		return ans;
	ans = 0;

	int mark = 0;
	for(int i = 1; i <= n; i++){
		if(rem - a[i] == 0){
			mark = 1;
			break;
		}
		else if(rem - a[i] > 0){
			if(go(rem - a[i], turn ^ 1) == 0){
				mark = 1;
				break;
			}
		}
	}

	return ans = mark;
}

int main()
{
	memset(dp, -1, sizeof(dp));
	cin >> n >> k;

	for(int i = 1; i <= n; i++)
		cin >> a[i];

	if(go(k, 0))
		cout << "First\n";
	else
		cout << "Second\n";
}

Measured memory_bytes: 7296
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 1000000007
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = [SS() for _ in range(2)]

    # ドミノの縦横を判別 0行目だけ見れば良い
    t = []
    i = 0
    if N == 1:
        t.append('v')
    else:
        while i + 1 < N:
            if S[0][i] == S[0][i+1]:
                t.append('h')
                i += 2
            else:
                t.append('v')
                i += 1
        if S[0][-2] != S[0][-1]:
            t.append('v')
    # print(t)

    ans = 1
    if t[0] == 'h':
        ans *= 6
    else:
        ans *= 3
    ans %= MOD
    for i in range(len(t) - 1):
        if t[i] == 'h':
            if t[i+1] == 'h':
                ans *= 3
            else:
                ans *= 1
        else:
            if t[i+1] == 'h':
                ans *= 2
            else:
                ans *= 2
        ans %= MOD
    
    print(ans)
                
if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9904
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from heapq import *
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
job = defaultdict(list)
for _ in range(N):
	A, B = MAP()
	job[A].append(-B)

ans = 0
l = []

for i in range(1, M+1):
	for j in job[i]:
		heappush(l, j)
	if l:
		ans += -heappop(l)

print(ans)


Measured memory_bytes: 29420
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

struct Denk{
    vector<int> sw;
    int p=0;
    bool check(const vector<int>& onoff){
        int cnt=0;
        for(auto n:sw){
            if(onoff[n-1]) ++cnt;
        }
        return(cnt%2==p);
    }
};

int N,M;
vector<Denk> ds;
vector<int> onoff(11,0);
int ans=0;

bool judge(const vector<int>& sw)
{
    for(auto&& d:ds){
        if(!d.check(sw)) return false;
    }
    return true;
}

void check(int i, vector<int> sw){
    if (i >= N){//hantei
        if(judge(sw)){
            ++ans;
        }
        return;
    }
    //on
    sw[i]=0;
    check(i+1, sw);
    //off
    sw[i]=1;
    check(i+1, sw);
}

int main() {
#if LOCAL&01
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin>>N>>M;
    ds.resize(M);    
    for(auto&& d:ds){
        int k;
        cin>>k;
        for(int i=0;i<k;++i){
            int sw;
            cin>>sw;
            d.sw.push_back(sw);
        }
    }
    for(auto&& d:ds){
        cin>>d.p;
    }
    //全sw試す
    vector<int> sw(N,0);
    check(0,sw);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

from itertools import permutations
a, b = None, None
for num, tmp in enumerate(permutations(range(N), r=N)):
    dictord = []
    for i in tmp:
        dictord.append(i + 1)

    if dictord == P:
        a = num
    if dictord == Q:
        b = num
    if a is not None and b is not None:
        break

print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const int maxn = int(1e5) + 7, mod = int(1e9) + 7;
namespace Solve {
	int next[maxn][3], f[maxn], sum[maxn], n, ans;
	char str[maxn];
	int main() {
		scanf("%s", str);
		n = int(strlen(str));
		bool flag = true;
		for (int i = 1; str[i]; i++) flag &= str[i] != str[i - 1];
		if (flag) return 0 * puts("1");
		for (int i = 0; i < n; i++) sum[i + 1] = (sum[i] + 1 + (str[i] == 'b')) % 3;
		next[n][0] = next[n][1] = next[n][2] = n + 1;
		for (int i = n - 1; ~i; i--) {
			for (int j = 0; j < 3; j++) {
				next[i][j] = next[i + 1][j];
			}
			next[i][sum[i + 1]] = i + 1;
		}
		f[0] = 1;
		for (int i = 0; i <= n; i++) {
			for (int j = 1; j <= 2; j++) {
				if (next[i][(sum[i] + j) % 3] <= n) {
					f[next[i][(sum[i] + j) % 3]] = (f[i] + f[next[i][(sum[i] + j) % 3]]) % mod;
				}
			}
			if (i > 0 && sum[i] == sum[n]) ans = (ans + f[i]) % mod;
		}
		printf("%d\n", ans);
		return 0;
	}
}
int main() {
#ifdef AC
	freopen("../in", "r", stdin);
#endif
	return Solve::main();
}



Measured memory_bytes: 2304
#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 euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int a,b;
  cin >> a >> b;
  if((a +b) % 2 == 0){
    cout << (a+b)/2 << endl;
  }
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int res=0;
        while(n>0)
        {
            n/=k;
            res++;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int q;
	cin >> q;
	vector<bool> isprime(100001, true);
	isprime[1] = false;
	for(int i = 2; i <= 100000; i++){
		if(!isprime[i]) continue;
		int now = 2 * i;
		while(now <= 100000){
			isprime[now] = false;
			now += i;
		}
	}
	int cnt[100001] = {};
	for(int i = 2; i <= 100000; i++){
		cnt[i] = cnt[i - 1];
		if(isprime[i] && isprime[(i + 1) / 2]) cnt[i]++;
	}
	for(int i = 0; i < q; i++){
		int l, r;
		cin >> l >> r;
		cout << cnt[r] - cnt[l - 1] << endl;
	}
	return 0;
}

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

int main(){
  int a,b,c,k,sum = 0;
  cin >> a >> b >> c >> k;
  for(int i = 0;i<k;i++){
    if(a >= b&&b >=c) a = 2 * a;
    else if(b >= c&&b >=a) b = 2 * b;
    else if(c >= b&&c >=b) c = 2 * c;
  }
  sum = a + b + c;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] Args){
        final int n = Integer.parseInt(sc.next());
        long sum = 0;
        int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
        for(int i = 0; i<n; i++){
            final int a = Integer.parseInt(sc.next());
            max = Math.max(max, a);
            min = Math.min(min, a);
            sum += a;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}

Measured memory_bytes: 40480
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int i;
try (Scanner sc = new Scanner(System.in)) {
while (true) {
int n = sc.nextInt();
if (n == 0) { break; }
int[] scores = new int[n];
for (i = 0; i < scores.length; i++) {
scores[i] = sc.nextInt();
}
double average = 0, variance = 0, sum = 0;
for(i=0; i<n; i++){
    sum += scores[i];
}
average = sum/n;
for(i=0; i<n; i++){
variance = variance + (scores[i]-average)*(scores[i]-average);
}
variance = variance/n;
System.out.println(Math.sqrt(variance));
}
}
}
}



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

def main():
    N, M = map(int, input().split())
    cd = {}
    FAIL = (10 ** 3) * (10 ** 5) + 1
    for _ in range(M):
        ai, _ = map(int, input().split())
        ci = sum(1 << (int(i) - 1) for i in input().split())
        keys = list(cd.keys())
        for i in keys:
            cd[i | ci] = min(cd.get(i | ci, FAIL), cd[i] + ai)
        cd[ci] = min(cd.get(ci, FAIL), ai)
    print(cd.get((1 << N) - 1, -1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  int c = 0;
  cin >> a >> b;
  vector<int> v(b);
  for (int i=0; i<b; i++){
    cin >> v.at(i);
    c += v.at(i);
  }
  if (a >= c) cout << a-c;
    else cout << "-1";
}

Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)


template<typename T>
T gcd(T n, T m){

    if(m > n)  return gcd(m, n);

    T r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, k; cin >> n >> k;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll vmax = *max_element(a, a+n);
    if(vmax < k){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    ll g = gcd(a[0], a[1]);
    reps(i, 2, n){
        g = gcd(g, a[i]);
    }

    if(k % g == 0){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d;
    e=a*b;
    f=c*d;
    if(e>f){
        cout<<e<<endl;
    }
    else if(f>e){
        cout<<f<<endl;
    }
    else if(e==f){
        cout<<e<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 *      ABC 55 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 02:34:20
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    cout << N * 800 - (N / 15) * 200 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull  unsigned long long
#define vll  vector <long long>
#define pll pair <long long,long long>
#define f first
#define s second
#define pq priority_queue
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);
int main()
{
    ll a,b,k;
    cin>>k>>a>>b;
    bool s=true;
   for(ll i=a;i<=b;i++)
   {
       if(i%k==0)
       {
          cout<<"OK"<<endl;
          s=false;
          break;
       }


   }
   if(s)
    cout<<"NG"<<endl;


}



Measured memory_bytes: 3548
// https://atcoder.jp/contests/abc174/tasks/abc174_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, D, ans = 0;
    cin >> N >> D;
    REP(i, N) {
        int X, Y;
        cin >> X >> Y;
        double t = hypot(X, Y);
        if (t <= D) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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



int main(void){
    string po;
    cin >> po;
    long long int K;
    scanf(" %lld",&K);
    for(int i=0;i<po.size();i++){
        if(i<K&&po[i]!='1'){printf("%c",po[i]);return 0;}
    }
    printf("1");
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    long long x, k , d;
    cin >> x >> k >> d;
    x = abs(x);
    long long ret;
    if (x/d > k)
    {
        ret = x - d*k;
    }
    else
    {
        long long e = x/d;
        k -= e;
        x -= e*d;
        if (k%2==1) x = abs(x-d);
        ret = x;
    }
    cout<< ret <<endl;  
    return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(1000)

def rec(l, r, c):
    if l==r:
        return
    
    m = (l+r)//2
    
    for i in range(l, m+1):
        for j in range(m+1, r+1):
            a[i][j] = c
    
    rec(l, m, c+1)
    rec(m+1, r, c+1)

N = int(input())
a = [[-1]*N for _ in range(N)]
rec(0, N-1, 1)

for i in range(N):
    ans = []
    
    for j in range(i+1, N):
        ans.append(a[i][j])
    
    print(*ans)

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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pd pair<double, int>
#define pib pair<pi, bool>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 200001
#define MAXL 1000001
#define mod 1000000007

signed main()
{
  int n, m;
  cin >> n >> m;
  set<int> is_good;
  lli item[n];
  vector<int> adj[n];
  for (int i = 0; i < n; i++)
    cin >> item[i];
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    bool can = true;
    for (int j = 0; j < adj[i].size(); j++)
    {
      if (item[adj[i][j]] >= item[i])
      {
        can = false;
        break;
      }
    }
    if (can)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9540
#include<iostream>
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define lli long long int
#define all(v) (v.begin(),v.end())
#define fr first
#define sc second
#define mp make_pair
using namespace std;
int a[100];

int main()
{
    int n,i,j,k;
    cin>>n>>k;
    int a[n];
    rep(i,n) cin>>a[i];
    int dp[n+1];
    for(i=0;i<n;i++) dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i-j>=0) dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }

    }
    cout<<dp[n-1]<<endl;
}


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

int main()
{
    int N;
    cin >> N;
    long long sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    cout << sum << endl;
}


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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a * b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char str[1000];
  //H とW と正解を格納する変数ans
  long h, w, ans;
  
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%ld %ld", &h, &w);
  
  if(h == 1 || w== 1){
    ans = 1;
  }else if(h % 2 == 0 || w % 2 == 0){
    ans = w * h / 2;
  }else{
    ans = (w * h + 1)/ 2;
  }
  
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 2064
using System;


class sample4{
    static void Main(string[] args){

            string[] str_number = Console.ReadLine().Split(' ');
            int a = int.Parse(str_number[0]);
            int b = int.Parse(str_number[1]);

            if((a <= -1000) || (b <= -1000)){
                Console.WriteLine("数値は-1000以上の値を入力してください。");
                Environment.Exit(0);
            }else if((a >= 1000) || (b >= 1000)){
                Console.WriteLine("数値は1000以下の値を入力してください。"); 
                Environment.Exit(0);
            }
            
            if( a < b){
                Console.WriteLine("a < b");
            }else if( a > b){ 
                
                 Console.WriteLine("a > b");
            }else if(a == b){ 
           
                 Console.WriteLine("a == b");
            }
    }
}



Measured memory_bytes: 17944
#include <iostream>

int main() {
    int n, m, k; std::cin >> n >> m >> k;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (((n-i)*j + (m-j)*i) == k) {
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
D = list(map(str, input().split()))
while True:
    flg = True
    num = str(N)
    for i in range(len(num)):
        if num[i] in D:
            flg = False
            break
    if flg is True:
        print(int(num))
        break
    N += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;


void solve(){
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    int x[n+10];
    int y[m+10];
    rep(i,n){
        cin >> x[i];
    }
    rep(i,m){
        cin >> y[i];
    }
    /*
    int tmp = 0;
    rep(i,n){
        tmp = max(tmp,x[i]);
    }
    int tmp2=INF;
    rep(i,m){
        tmp2 = min(tmp2, y[i]);
    }

    string ans = "War";
    if(tmp<tmp2) {
    //tmp+1 ~ tmp2までのすべての整数値
        for(int i=tmp+1; i<=tmp2; i++){
            if(X < i && i <= Y) ans = "No War";
        }
    }
    cout << ans << endl;
    */
    string ans = "War";
    for(int z = -100; z<=100; z++){
        bool b=true;
        if(X>=z) b=false;
        if(z>Y) b=false;
        rep(i,n){
            if(x[i]>=z) b=false;
        }
        rep(i,m){
            if(y[i]<z) b=false;
        }
        if(b) ans = "No War";
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n,m;
    cin >> n >> m;
    vector<int64_t> a(n);
    vector<pair<int64_t,int64_t>> p(m);
    //vector<int64_t> c(m);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int l=0;
    for(int i=0;i<m;i++){
        cin >> p[i].second >> p[i].first; 
        //l += b[i];
    }
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    /*
    rep(i,m){
        cout<<p[i].second<<" "<<p[i].first<<endl;
    }
    */
    int j=0;
    rep(i,n){
        if(j<m &&p[j].second>=1 && p[j].first>a[i]){
            a[i] = p[j].first;
            p[j].second--;
        }
        if(p[j].second==0){
            j++;
        }
    }
    int64_t sum = 0;
    for(int i=0;i<n;i++){
        sum += a[i];
        //cout<<a[i]<<" ";
    }
    cout <<sum <<endl;
}

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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    int ans = 0;
    rep(i, 3){
        int tmp;
        cin >> tmp;
        ans += tmp;
    }
    cout << (ans <= 21 ? "win" : "bust") << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
#O(ElogV)
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

################################
n,w = n, n - 1

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y,z = map(int,input().split())
    edge[x - 1].append([z,y - 1])
    edge[y - 1].append([z,x - 1]) 

q, k = [int(x) for x in input().split()]

k_dis = dijkstra_heap(k - 1)

for _ in range(q):
    s, g = [int(x) for x in input().split()]
    print(k_dis[s - 1] + k_dis[g - 1])


Measured memory_bytes: 100256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

string ans = "No";
int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a*b) % 2 == 0 || (c + d) % 2 == 0) { ans = "Yes"; }
	cout << ans << endl;
}


Measured memory_bytes: 3192
A,B,C=map(int,input().split())
x=A*7+B
y=C//(A*7+B)
z=x*y
v=C-z

if (A*7)<v<x:
    print((y+1)*7)
else:
    coin=0
    day=0
    while coin<v:
        coin+=A
        day+=1
    print(y*7+day)


Measured memory_bytes: 5596
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int W = int.Parse(s[0]);
        int a = int.Parse(s[1]);
        int b = int.Parse(s[2]);
        Console.WriteLine(
            a + W >= b && b >= a ||
            b + W >= a && a >= b ?
            0 :
            Math.Min(Math.Abs(b - a - W), Math.Abs(a - b - W))
            );
    }

}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll f[100001];
ll power(ll a, ll b)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
ll InverseEuler(ll n)
{
 return power(n,MOD-2);
}
ll C(ll n, ll r)
{
 return (f[n]*((InverseEuler(f[r]) * InverseEuler(f[n-r])) % MOD)) % MOD;
}
int main()
{  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    f[0] = 1;
	for(int i = 1 ; i <= 100000 ; i++)
		f[i] = (f[i-1]*i)%MOD;
    cin>>n>>k;
    ll a[n+1];
    for(int x=1;x<=n;x++)
        cin>>a[x];
    sort(a+1,a+n+1);
    ll g=0;
    for(int x=1;x<=n;x++)
    {   if(n-x>=k-1)
        {g+=((a[x])*C(n-x,k-1))%MOD;
        g%=MOD;
        }
    }
    ll j=0;
    for(int x=k; x<=n; x++){
        j+=(a[x]*C(x-1,k-1))%MOD;
        j%=MOD;
    }
    cout<<(MOD+(j-g))%MOD;
}


Measured memory_bytes: 1792
import copy
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = True
if n % 2 == 1:
    if a[0] != 0:
        print(0)
    else:
        ans = [i for i in range(2, n, 2) for j in range(2)]
        ans.insert(0, 0)
        if ans != a:
            print(0)
            flag = False
    if flag:
        print((2**((n - 1) // 2)) % (10**9 + 7))

else:
    ans = [i for i in range(1, n, 2) for j in range(2)]
    if ans != a:
        print(0)
        flag = False
    if flag:
        print((2**(n // 2)) % (10**9 + 7))


Measured memory_bytes: 14452
#include <iostream>

int main()
{
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;
    
    bool leftout  = x - r < 0;
    bool rightout = x + r > W;
    bool upout    = y + r > H;
    bool downout  = y - r < 0;
    
    if (leftout || rightout || upout || downout)
        std::cout << "No" << std::endl;
    else
        std::cout << "Yes" << std::endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){
    int N = 0;
    scanf("%d",&N);
    if(N/100 == 7){
        printf("Yes\n");
        return 0;
    }else if((N/10) % 10 == 7){
        printf("Yes\n");
        return 0;
    }else if(((N%100)%10)==7){
        printf("Yes\n");
        return 0;
    }else{
        printf("No\n");
    }
    return 0;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (num i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int inf = 0x3f3f3f3f;
bool vis[2019];
num l, r, ans = inf;

int main() {
    cin >> l >> r;
    circ (i, l, r) {
        loop (j, 2019) {
            if (vis[j]) {
                ans = min(ans, (i % 2019 * j) % 2019);
            }
        }
        vis[i % 2019] = 1;
        if (ans == 0)  break;
    }
    cout << ans << endl;
}


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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

int main() {
  cout << setprecision(18);
  u64 K, S;
  cin >> K >> S;
  u64 res = 0;
  for (u32 i = 0; i <= K; ++i) {
    for (u32 j = 0; j <= K; ++j) {
      if (S - (i + j) <= K) {
        ++res;
      }
    }
  }
  cout << res << endl;
}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s==u)
        a--;
    else
        b--;
    cout << a << " " << b;
    return 0;
}



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

int main() {
	ll N, A, B; scanf("%lld%lld%lld", &N, &A, &B);
	ll diff = B - A;

	ll ans;
	if ((diff & 1) == 0) ans = diff / 2;
	// 差が奇数の時、近い方が端へ行き、一度戦った後、近づく
	else {
		ll distance = min(A, N - B + 1);
		ans = distance + (diff - 1) / 2;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	int d,t,s; cin>>d>>t>>s;
	cout << (d>t*s ? "No":  "Yes") << endl;
}

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

	int a[10];

	 for(int i=0; i<10; i++){

	 	cin >> a[i];
	 }

	 for(int t=0; t<9; t++){

	 	for(int s=t+1; s<10; s++ ){

	 		if(a[s]>a[t]){

	 			int num=a[s];

	 			a[s]=a[t];

	 			a[t] = num;
	 		}
	 	}
	 }

	 for (int j=0; j<3; j++){

	 	cout << a[j] << endl;
	 }
}

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

int main(){
  int N,M,ans,a =500000000;
  cin >> N >> M;
  vector<int> sx(N),sy(N),cx(M),cy(M);
  for(int i=0;i<N;i++){
    cin >> sx.at(i) >> sy.at(i);
  }
   for(int i=0;i<M;i++){
    cin >> cx.at(i) >> cy.at(i);
  }
  for(int i=0;i<N;i++){
   for(int j=0;j<M;j++){
     if(a>abs(sx.at(i)-cx.at(j))+abs(sy.at(i)-cy.at(j))){
       a = abs(sx.at(i)-cx.at(j))+abs(sy.at(i)-cy.at(j));
       ans = j+1;
     }
   }
    cout << ans <<endl;
    a = 500000000;
  }
}

Measured memory_bytes: 256