akhauriyash/Code-Regression huggingface dataset:
/*input
4
20 11 9 24

*/

#include <bits/stdc++.h>

using namespace std;

vector<int> v;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n; int xx = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    v.emplace_back(x);
    xx ^= x;
  }

  for (int i = 0; i < n; ++i) {
    int k = (n & 1) ? 0 : v[i];
    cout << (k ^ xx) << ' ';
  }

  return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll gcd(ll a, ll b){
    if(!a) return b;
    return gcd(b%a, a);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a, b, c; cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 896
import numpy as np

h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

ans = []
for i, e in enumerate(a, 1):
    ans += [i] * e

ans = np.array(ans, dtype=np.int64)
ans = ans.reshape((h, w))

for i in range(1, h, 2):
    ans[i] = ans[i][::-1]

for ar in ans:
    print(*ar)


Measured memory_bytes: 14428
#include <iostream>

int main(){
  int age_of_takahashi;
  std::cin >> age_of_takahashi;
  std::cout << ((age_of_takahashi > 2 && age_of_takahashi < 8 && (age_of_takahashi % 2 != 0)) ? "YES" : "NO");  
  return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <bitset>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;



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

	string t1 = "erase", t2 = "eraser", t3 = "dream", t4 = "dreamer";

	int cur = sz(s) - 1;
	for (; cur >= 0; ) {
		if (s[cur] != 'r') {
			if (cur >= 4 && s.substr(cur - 4, 5) == t1) {
				cur -= 5;
				continue;
			} 
			if (cur >= 4 && s.substr(cur - 4, 5) == t3) {
				cur -= 5;
				continue;
			} 
		} else {
			if (cur >= 5 && s.substr(cur - 5, 6) == t2) {
				cur -= 6;
				continue;
			} 
			if (cur >= 6 && s.substr(cur - 6, 7) == t4) {
				cur -= 7;
				continue;
			} 
		}
		cout << "NO" << endl;
		return 0;
	}

	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
int f[100000],a[100000];

using namespace std;

int main()
{
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    f[1]=0;
    f[2]=abs(a[1]-a[2]);
    for (int i=3;i<=n;i++)
        f[i]=min(abs(a[i-1]-a[i])+f[i-1],abs(a[i-2]-a[i])+f[i-2]);
    cout<<f[n];
}


Measured memory_bytes: 1024
import qualified Data.ByteString.Char8 as C
import           Data.Maybe ( fromJust )

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,y] <- getParms
  putStrLn $ otsdm n y

type Yen = Int
type Mai = Int
type Pochi = (Int,Int,Int) -- #s of 10000,5000,1000 bills

otsdm'
  :: Mai -> Yen -> [Pochi]
otsdm' n y
  = [(a,b,n-a-b) 
      | let a0 = y `quot` 10000
      , a <- [0 .. a0]
      , let b0 = (y - 10000*a) `quot` 5000
      , b <- [0 .. b0]
      ]

gok
  :: Pochi -> Yen
gok (a,b,c) = 10000*a +5000*b + 1000*c 

otsdm
  :: Mai -> Yen -> String
otsdm n y
  | null os   = "-1 -1 -1"
  | otherwise = show a ++ " " ++ show b ++ " " ++ show c
  where
    os = filter (\o -> y == gok o) $ otsdm' n y
    (a,b,c) = head os

Measured memory_bytes: 636
#include"bits/stdc++.h"
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a + b == c || a + c == b || b + c == a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
from collections import defaultdict
n,k=map(int,input().split())
a=list(map(int,input().split()))
dd=defaultdict(lambda:0)
for aa in a: dd[aa]+=1

diff=len(dd)-k
if diff<=0:
  print(0)
  exit()
l=[x for x in dd.values()]
l.sort()
print(sum(l[:diff]))


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

int main()
{
  long long a=0,b=0;
  int n,x,y;
  char c;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>c>>y;
    if(c=='(')a+=y;
    else b+=y;
    if(a==b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int,int> pii;
const int mod = (int) 1000000007;
const int inf = (int) 2e18;
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n;
    cin >> n;
    map<string, int> hash;
    hash["AC"] = 0;
    hash["WA"] = 0;
    hash["TLE"] = 0;
    hash["RE"] = 0;
    while(n--){
        string s;
        cin >> s;
        hash[s]++;
    }
    cout << "AC x " << hash["AC"] << "\n";
    cout << "WA x " << hash["WA"] << "\n";
    cout << "TLE x " << hash["TLE"] << "\n";
    cout << "RE x " << hash["RE"] << "\n";
}

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
typedef pair<int,int> pi;
pi zlt;
map<pi,int> cnt,bz;
set<int> s[maxn];
set<int>::iterator it;
queue<pi> dl;
int fa[maxn];
int i,j,k,l,t,n,m,x,y,z,ca;
bool czy;
int getfa(int x){
    return fa[x]?fa[x]=getfa(fa[x]):x;
}
int main(){
    scanf("%d",&n);
    fo(i,1,2*(n-1)){
        scanf("%d%d",&j,&k);
        if (j>k) swap(j,k);
        zlt=make_pair(j,k);
        cnt[zlt]++;
        if (cnt[zlt]==1){
            s[j].insert(k);
            s[k].insert(j);
        }
        if (cnt[zlt]>1&&!bz[zlt]){
            dl.push(zlt);
            bz[zlt]=1;
        }
    }
    czy=1;
    ca=n-1;
    while (ca--){
        x=y=-1;
        while (!dl.empty()){
            j=getfa(dl.front().first);
            k=getfa(dl.front().second);
            dl.pop();
            if (j!=k){
                x=j;y=k;
                break;
            }
        }
        if (x==y&&x==-1){
            czy=0;
            break;
        }
        if (s[x].size()<s[y].size()) swap(x,y);
        fa[y]=x;
        it=s[y].begin();
        while (it!=s[y].end()){
            z=*it;
            it++;
            s[z].erase(s[z].find(y));
            if (z==x) continue;
            //if (s[x].find(z)==s[x].end()) s[x].insert(z),s[z].insert(x);
            if (x<z) zlt=make_pair(x,z);else zlt=make_pair(z,x);
            cnt[zlt]++;
            if (cnt[zlt]==1){
                s[x].insert(z);
                s[z].insert(x);
            }
            if (cnt[zlt]>1&&!bz[zlt]){
                dl.push(zlt);
                bz[zlt]=1;
            }
        }
        s[y].clear();
    }
    if (czy) printf("YES\n");else printf("NO\n");
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	if (n == 1)cout << "Hello World" << endl;
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();
    let mut candidate: Vec<Vec<char>> = vec![];
    'outer: for start in 0..s.len() {
        let mut temp = s.clone();
        for i in 0..t.len() {
            let pos = start + i;
            if pos >= s.len() {
                break 'outer;
            }
            if temp[pos] != '?' && temp[pos] != t[i] {
                continue 'outer;
            }
            temp[pos] = t[i];
        }
        for i in 0..s.len() {
            if temp[i] == '?' {
                temp[i] = 'a';
            }
        }
        candidate.push(temp);
    }
    candidate.sort();
    if candidate.is_empty() {
        println!("UNRESTORABLE");
    } else {
        for c in candidate[0].iter() {
            print!("{}", c);
        }
        println!("");
    }
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int n;
  cin >> n;

  string s = to_string(n);

  if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

vector<int> n_prime(int n) {
	vector<int> ret;
	vector<bool> is_prime(n + 1, 1);
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			ret.push_back(i);
			for (int j = i + i; j <= n; j += i) is_prime[j] = 0;
		}
	}
	return ret;
}

vci primes;
vci cnt;
int MAX = 50000;

void solve() {
	cnt.assign(MAX + 10, 0);
	
	int size = (int)primes.sz;
	for_(i, 0, size) {
		for_(j, i, size) {
			int t = primes[i] + primes[j];
			if (t > MAX) break;
			cnt[t]++;
		}
	}
}


int main() {
	int n;
	primes = n_prime(MAX);
	solve();
	
	while (1) {
		cin >> n; if (n==0) break;
		cout << cnt[n] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(void){
   int a[100][100],b[100],c[100];
   int i,j,n,m;
   scanf("%d %d",&n,&m);
   for(i=0;i<n;i++){
       for(j=0;j<m;j++){
           scanf("%d",&a[i][j]);
           }
        }
    for(j=0;j<m;j++)
    scanf("%d",&b[j]);
    for(i=0;i<n;i++){
        c[i]=0;
        for(j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
        }
    }
        for(i=0;i<n;i++){
            printf("%d\n",c[i]);
        }
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    double sum = 0;
    vector<double> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += 1 / v[i];
    }
    cout.setf(ios::fixed);
    cout << setprecision(10) << 1 / sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll w, a, b;
  cin >> w >> a >> b;
  if(b>=a&&b<=a+w){
    print(0);
  }
  else if(b+w>=a&&b+w<=a+w){
    print(0);
  }
  else if(a+w<b){
    print(b - a - w);
  }
  else if(b+w<a){
    print(a - b - w);
  }
}

Measured memory_bytes: 256
INIT = 1
n, m = map(int, input().split())
dp = [INIT for i in range(n + 1)]

for i in range(m):
    a = int(input())
    dp[a] = 0

for i in range(2, n + 1):
    dp[i] = (dp[i - 1] + dp[i - 2]) * dp[i]

print(dp[n] % 1000000007)


Measured memory_bytes: 462744
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a,q,b,e,k;
    cin >> n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin >> a;
        deq.emplace_back(a);
    }
    cin >> q;
    int count = 0;
    for (int j=0;j<q;j++) {
        cin >> b >> e >> k;
        for (b;b<e;b++) {
            if ( deq[b]==k) {
                count = count + 1;
            }
        }
        std::cout << count << std::endl;
        count = 0;
    }
}



Measured memory_bytes: 3116
def main():
    k = int(input())
    a = list(map(int, input().split()))
    if a[0]%k == 0:
        print("OK")
    elif int(a[0]/k) == int(a[1]/k):
        print("NG")
    else:
        print("OK")
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))


class B1DimensionalWorldsTale {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n, m, x, y;
      in >> n >> m >> x >> y;
      vector<int> vx(n);
      REP(i, n) in >> vx[i];
      vector<int> vy(m);
      REP(i, m) in >> vy[i];
      sort(vx.begin(), vx.end(), greater<int>());
      sort(vy.begin(), vy.end(), less<int>());
      FOR(i, x + 1, y + 1) {
        if (vx[0] < i && vy[0] >= i) {
          out << "No War" << endl;
          return;
        }
      }
      out << "War" << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  B1DimensionalWorldsTale solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

char s[100010];
int K;

char n(char c) {
  int i = (int)c-(int)'a';
  return (char)((i+1)%26 + (int)'a');
}

void rotate(int i) {
  s[i] = n(s[i]);
}

int main() {
  cin >> s;
  cin >> K;
  int l = strlen(s);
  int x = K;
  int i = 0;
  while (x > 0 && i < l) {
    int d = ((int)'a' - (int)s[i] + 26) % 26;
    if (d > x) {
      i++;
      continue;
    }
    s[i] = 'a';
    x -= d;
    i++;
  }
  for (int j=0; j<(x%26); j++) rotate(l-1);
  cout << s << "\n";
  return 0;
}



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

namespace abc122_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var NQ = (Console.ReadLine().Split().Select(x => long.Parse(x))).ToList();
            var S = Console.ReadLine();
            var sr = new List<int>();
            var ru = 0;

            sr.Add(0);
            for (int i = 1; i < S.Length ; i++) 
            {
                if (S[i - 1] == 'A' && S[i] == 'C')
                    ru++;
                sr.Add(ru);
            }

            var rl = new List<int>();

            for (int i = 0; i < NQ[1]; i++)
            {
                var lr = (Console.ReadLine().Split().Select(x => int.Parse(x)-1)).ToList();
                rl.Add(sr[lr[1]] - sr[lr[0]]);
            }

            foreach (int r in rl) Console.WriteLine(r);

        }
    }
}


Measured memory_bytes: 18236
# 素因数分解 ソート済みリスト (素因数,指数)
import math
N = int(input())
dict_count = {}
for i in range(1,N+1):
    dict_count[i] = 0

def factoring(n):
    sup = math.floor(pow(n,1/2))
    n_new = n
    for i in range(2,sup + 1):
        if n % i == 0:
            n_new = n // i
            dict_count[i] += 1
            break
    if n == n_new:
        dict_count[n_new] += 1
        return
    return factoring(n_new)

for i in range(2,N+1):
    factoring(i)

ans = 1
for i in range(1,N+1):
    ans *= dict_count[i] + 1
    ans %= 10**9 + 7
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        cout << s[i];
        if(i==3) cout <<" ";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
fn solve(s: String) -> usize {
    s.match_indices("1").count()
}

fn main() {
    let s = read_1();

    println!("{}", solve(s));
}

fn read_1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2096
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  else if (N % 2 == 0) return Pow(A * A % MOD2, N / 2);
  else return A * Pow(A * A % MOD2, N / 2) % MOD2;
}

int main(){

  ll N, M, K; cin >> N >> M >> K;

  ll DP[N], nCr[K + 1];
  DP[N - 1] = M;
  for (int i = N - 2; i >= 0; i--){
    DP[i] = DP[i + 1] * (M - 1); DP[i] %= MOD2;
  }

  nCr[0] = 1;
  for (ll i = 1; i <= K; i++){
    nCr[i] = nCr[i - 1] * (N - i); nCr[i] %= MOD2;
    nCr[i] *= Pow(i, MOD2 - 2); nCr[i] %= MOD2;
  }

  ll ans = 0;
  for (int i = 0; i <= K; i++){
    ans += DP[i] * nCr[i];
    ans %= MOD2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6696
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S,T;
	int A,B;
	string U;
	cin>>S>>T;
	cin>>A>>B;
	cin>>U;
	if (!S.compare(U)){
		A--;
	}
	if (!T.compare(U)){
		B--;
	}
	cout<<A<<" "<<B<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll pow2(ll x, ll n) { //x^n 計算量O(logn)
	ll ans = 1ll;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

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

	ll n, a, b;
	cin >> n >> a >> b;
	Array v(n,0);
	map<ll, ll> mp;
	REP(i, n) {
		cin >> v[i];
		mp[v[i]]++;
	}
	
	auto it = mp.end();
	ll count = 0;
	ll sum = 0;
	ll last = 0;
	ll num = 0;
	bool flag = true;
	do {
		it--;
		if (count + it->second <= a) {
			sum += it->first * it->second;
			count += it->second;
			num = it->second;
		}
		else {
			sum += it->first * (a - count);
			
			num = a - count;

			count = a;
		}
		last = it->first;

		if (count == a) {
			//cout << num << endl;
			break;
		}
		flag = false;
	
	} while (it != mp.begin());

	cout << fixed << setprecision(8)<< (double)sum/(double)count << endl;

	//(mp[last])C(num)
	ll nn = mp[last];

	if (flag) {
		//nnCa+...+nnCb
		ll ans2 = 0;
		ll ans1 = 1;
		for (int k = 1;k<=a; k++) {
			ans1 = ans1 * (nn - k + 1) / k;
		}
		ans2 += ans1;
		ll nnn = min(nn, b);
		for (int k = a + 1; k <=nnn; k++) {
			ans1 = ans1* (nn - k + 1) / k;
			ans2 += ans1;
		}
		cout << ans2 << endl;
		return 0;
	}

	//cout << nn << "C" << num << endl;
	
	if (nn-num < num) {
		num = nn - num;
	}

	ll ans = 1;
	for (int i = nn; i > nn - num; i--) {
		ans *= i;
		//cout << "a" <<ans<< endl;
	}
	for (int i = 1; i <= num; i++) {
		ans /= i;
		//cout << "b" << ans << endl;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

a = 0
b = 0
for i, x in  enumerate(itertools.permutations(range(1, n + 1))):
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=1145141;
int a[maxn],tree[maxn],h[maxn],ans[maxn];
int N,q;
struct Node{
	int l,r,pos;
};
Node que[maxn];
bool cmp(Node x,Node y){
	return x.r<y.r;
}
int lowbit(int n){
	return n&(-n);
}
void add(int n,int now){
	while(n<=N){
		tree[n]+=now;
		n+=lowbit(n);
	}
}
int sum(int n){
	int ret=0;
	while(n!=0){
		ret+=tree[n];
		n-=lowbit(n);
	}
	return ret;
}
int nxt=1;
int main(){
	cin>>N>>q;
	for(int i=1;i<=N;i++)cin>>a[i];
	for(int i=1;i<=q;i++){
		cin>>que[i].l>>que[i].r;
		que[i].pos=i;
	}
	sort(que+1,que+1+q,cmp);
	for(int i=1;i<=q;i++){
		for(int j=nxt;j<=que[i].r;j++){
			if(h[a[j]])add(h[a[j]],-1);
			add(j,1);
			h[a[j]]=j;
		}
		nxt=que[i].r+1;
		ans[que[i].pos]=sum(que[i].r)-sum(que[i].l-1);
	}
	for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 17400
import java.util.Scanner;


class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   long A = sc.nextLong();
   double B = sc.nextDouble();
   long b = (long) (B*(double)100+0.5);

   System.out.println(A*b/(long)100);
 
 }
}



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

int main() {
  vector<int>vec(3);
  for(int i=0;i<3;i++){  
    cin >> vec.at(i);
  }
  sort (vec.begin(),vec.end());
  
  int count;
  if(vec.at(0)+vec.at(1)==vec.at(2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main { 
  public static void main(String[] args)

{
	Scanner sc=new Scanner(System.in);
	String input=sc.nextLine();
	String[] inputArray =input.split(" ");
	
	if(inputArray.length==3)
	{
		int a = Integer.parseInt(inputArray[0]);  
        	int b = Integer.parseInt(inputArray[1]);
    	        int c = Integer.parseInt(inputArray[2]);
		
		
		if(a<b && b<c )
		{
			System.out.println("Yes");
		}
		
		else
		{
			System.out.println("No");
		}
		
		
	}
  }
}

Measured memory_bytes: 26252
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    vll a(n), s(n+1), t(n+1); 
    s[0] = 0;
    t[0] = 0;
    rep(i, n) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
        t[i+1] = t[i] ^ a[i];
    }
    
    // 左端 i を固定
    // OK : S_m - S_{i-1} = T_m ^ T_{i-1}
    
    /*
    rep(i, n+1){
        cout << s[i] << " " << t[i] << endl;
    }
    //*/
    
    ll ans = n;
    int i = 0;
    
    while(i < n){
        int l = i; int r = n;

        while(l+1 != r){
            int m = (l+r)/2;
            if(s[m+1] - s[i] == ll(t[m+1] ^ t[i])){
                l = m;
            }else{
                r = m;
            }
        }
        
        ll tmp = l - i;
        ans += tmp;
        i++;
    }
    
    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 7960
//Dijkstra-标程
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define VI vector<ll>
#define int long long
using namespace std;
 
#define INF 1e18
using P = pair<int, int>; // (distance, v)
struct edge {
  int to;
  int cost;
};
vector<int> dijkstra(vector<vector<edge>>& G, int start) {
  priority_queue<P, vector<P>, greater<P>> que;
  vector<int> d = vector<int>(G.size(), INF);
  d[start] = 0;
  que.push(P(0, start));
 
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) { continue; }
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[v] + e.cost < d[e.to]) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
  return d;
}
 
signed main() {
  int money = 1e15;
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;
  vector<vector<edge>> G1(n);
  vector<vector<edge>> G2(n);
  REP (i, m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    G1[u].push_back({v, a});
    G1[v].push_back({u, a});
    G2[u].push_back({v, b});
    G2[v].push_back({u, b});
  }
 
  vector<int> d1(dijkstra(G1, s));
  vector<int> d2(dijkstra(G2, t));
 
  vector<int> ans(n+1);
  ans[n] = 0;
  for (int i = n-1; i >= 0; i--) {
    ans[i] = max(ans[i+1], money - (d1[i] + d2[i]));
  }
 
  REP (i, n) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 19012
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int main() {
  ll x;
  cin >> x;
  ll cnt = x / 11LL;
  if( cnt * 11LL < x ) ++cnt;
  ll ans = cnt * 2LL;
  if( cnt * 11LL - 5 >= x ) --ans;
  
  cout << ans << endl;
  return 0;
}


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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<int> vec;
    for(int i = 0; i < n + n; ++ i) {
        int x;
        cin >> x;
        vec.push_back(x);
    }
    sort(vec.begin(), vec.end());
    int ans = 0;
    for(int i = 0; i < n + n; i += 2) {
        ans += vec[i];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		// yes or no for each row and col
		// 2 ^ H * 2 ^ W
		// 2 ^ (H + W)
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		int k = scanner.nextInt();
		// System.out.println("h: " + h);
		// System.out.println("w: " + w);
		int[][] grid = new int[h][w];
		for (int i = 0; i < h; i++) {
			char[] nextLine = scanner.next().toCharArray();
			// System.out.println("nextLine size: " + nextLine.length);
			for (int j = 0; j < w; j++) {
				grid[i][j] = nextLine[j] == '.' ? 0 : 1;
			}
		}
		int ans = solve(h, w, k, grid);
		System.out.println(ans);
	}

	public static int solve(int h, int w, int K, int[][] grid) {
		int ans = 0;
		int maxH = 1 << h;
		int maxW = 1 << w;
		for (int i = 0; i < maxH; i++) {
			for (int j = 0; j < maxW; j++) {
				int black = 0;
				for (int k = 0; k < h; k++) {
					for (int l = 0; l < w; l++) {
						// row and col are not selected
						// 8: 101
						// i >> k
						if (grid[k][l] == 1 && ((i >> k) & 1) == 0 && ((j >> l) & 1) == 0) {
							black++;
						}
					}
				}
				if (K == black) {
					ans++;
				}
			}
		}
		return ans;
	}
}


Measured memory_bytes: 35996
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	i64 ans = 0;
	rep(i, 0, n) {
		int a;
		cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int n,m,q;

int a[50],b[50], c[50],d[50];

vector<int> A(50);

set<vector<int>> st;

int dfs(int s, int length){
//  cout << s << " " << length << endl;
  int ret=0;

  if(length < n){
    A[length] = s;
    FOR(i,s,m+1){
      chmax(ret, dfs(i,length+1));
    }
  }else{
    int tmp = 0;
    REP(i,q){
      if(A[b[i]]-A[a[i]]==c[i])tmp += d[i];
    }
    chmax(ret,tmp);
  }
  return ret;
}


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

  REP(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }


  int ans = 0;
  FOR(i,1,11)chmax(ans,dfs(i, 0));
  cout << ans << endl;
}



Measured memory_bytes: 3664
n,t=gets.split(" ").map{|e| e.to_i}
arr=[]
n.times{
	a,b=gets.split(" ").map{|e| e.to_i}
	if b<=t then
		arr<<a
	end
}
if arr.size==0 then
	puts "TLE"
else
	puts arr.min
end

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

int main() {
  int n;
  cin >> n;
  int p[n];
  int place[n];
  rep(i,n) cin >> p[i];
  rep(i,n) place[p[i]-1] = i;  // 0-indexed
  ll sum = 0;

  vector<int> L1(n,1), L2(n,1), R1(n,1), R2(n,1);  // distance
  L2[0] = 0;
  R2[n-1] = 0;
  rep(i,n-1) {
    int x = place[i];
    sum += (L1[x]*R2[x] + R1[x]*L2[x]) * ((ll)i+1);

    int l1 = x-L1[x], l2 = l1-L2[x];
    int r1 = x+R1[x], r2 = r1+R2[x];

    if (l1 > -1) {
      R1[l1] += R1[x];
      R2[l1] = R2[x];
    }
    if (l2 > -1) {
      R2[l2] += R1[x];
    }
    if (r1 < n) {
      L1[r1] += L1[x];
      L2[r1] = L2[x];
    }
    if (r2 < n) {
      L2[r2] += L1[x];
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int l[10];
int N, A, B, C;
int dfs(int cur, int a, int b, int c)
{
    if (cur == N)
    {
        if (min({a, b, c}) > 0)
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else
            return 1000000;
    }

    int ret1 = dfs(cur + 1, a, b, c);
    int ret2 = dfs(cur + 1, l[cur] + a, b, c) + 10;
    int ret3 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret4 = dfs(cur + 1, a, b, c + l[cur]) + 10;

    return min(min(ret1, ret2), min(ret3, ret4));
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);

    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; ++i)
        cin >> l[i];
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n==1 && m!=1) printf("%d",m-2);
	if(n!=1 && m==1) printf("%d",n-2);
	if(n==1 && m==1) putchar('1');
	if(n!=1 && m!=1) printf("%lld",(long long)(n-2)*(m-2));
	return 0;
}

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



int main(){
  int n,q;
  int i,j;
  int *N;
  int x;
  int count=0;
   

  scanf("%d",&n);
  N=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&N[i]);
  

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&x);
    for(j=0;j<n;j++){
      if(x==N[j]){
        count+=1;
        break;
      }
    }
  }
  
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
#include <stdint.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define int long long
typedef vector<int> vi;
typedef pair<int, int> pii;
const double PI = acos(-1.0);
const int mod = 1e9 + 7;
int pows(int a , int b){int res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
const int N = 1e9+5;
void init() {
  ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
}

void solve(){
    string s1 , s2 ;
    cin >> s1 >> s2 ;
    int l1 = s1.length() , l2 = s2.length() ;
    int dp[l1+1][l2+1] ;
    //memset(dp,0,sizeof dp) ;
    for(int i = 0 ; i <= l1 ; i++){
        for(int j = 0 ; j <= l2 ; j++){
            if(i==0 || j==0)
                dp[i][j] = 0 ;
            else if(s1[i-1]==s2[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]) ;
        }
    }
    string ans = "" ;
    int i = s1.length() , j = s2.length() ;
    for(  ; i>=0 && j>=0 ; ){
        if(i!=0 && dp[i][j] == dp[i-1][j])
            i-- ;
        else if(j!=0 && dp[i][j-1]==dp[i][j])
            j-- ;
        else{
           ans = s1[i-1] + ans ;
            i--;j--;
        }
    }
    string anss = ans.substr(1);
    cout << anss << endl ;
}
int32_t main()
{
    init();
    int t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 70656
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 500010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
const int mod=1e9+7;
int fac[N],inv[N];
int n,m;
inline int C(int n,int m){if(n<m)return 0;return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline int Z(int x){return x>=mod?x-mod:x;}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();int ans=0;
	fac[0]=1;
	for(register int i=1;i<N;i++)fac[i]=1LL*fac[i-1]*i%mod;
	inv[0]=inv[1]=1;
	for(register int i=2;i<N;i++)inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(register int i=2;i<N;i++)inv[i]=1LL*inv[i-1]*inv[i]%mod;
	for(register int k=0,tag=1;k<=n;k++,tag=mod-tag)
	{
		ans=Z(ans+1LL*tag*C(n,k)%mod*C(m,k)%mod*C(m-k,n-k)%mod*C(m-k,n-k)%mod*fac[k]%mod*fac[n-k]%mod*fac[n-k]%mod);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 7652
n,m,c = map(int,input().split())
b = [int(x) for x in input().split()]
ans = []
for _ in range(n):
    a = input().split()
    s = c
    for i in range(m):
        s += int(a[i])*b[i]
    ans += [s>0]
print(sum(ans))

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[2]={0};
    string s;
    cin >> s;
    rep(i,(int)s.length()) {
        if(s[i]=='0') {
            c[0]++;
        }
        else {
            c[1]++;
        }
    }
    cout << 2*min(c[0],c[1]) << endl;
    return 0;
}

Measured memory_bytes: 512
roll = [
(0,1,2,3,4,5),
(1,5,2,3,0,4),
(2,1,5,0,4,3),
(3,1,0,5,4,2),
(4,0,2,3,5,1),
(5,4,2,3,1,0)]

def zero_move_to_left(xi):
    r = roll[xi.index(0)]
    return [xi[ri] for ri in r]

def sort_middle_face(xi):
    m = xi[1:-1] 
    min_m = min(m)
    while m[0] != min_m:
        m = [m[1],m[3],m[0],m[2]]
    return xi[:1] + m + xi[-1:]

import sys
f = sys.stdin


str2i = {'Blue':0, 'Cyan':1, 'Green':2, 'Magenta':3, 'Red':4, 'Yellow':5}

import collections
while True:
    n = int(f.readline())
    if n == 0:
        break
    c = collections.Counter()
    for i in range(n):
        xi = [str2i[w] for w in f.readline().split()]
        xi = zero_move_to_left(xi)
        xi = sort_middle_face(xi)
        c[tuple(xi)] += 1
    print(n - len(c))

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




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

    //入力読み込み

    int i;
    int count; //今AGCTがいくつ続いているか
    int m; //

    count=0; 
    m =0;

    for(i=0; i< S.size(); i++){
        if(S.at(i)!='A' && S.at(i)!='G' && S.at(i)!='C'&& S.at(i)!='T'){
            m = max(m, count);
            count =0;
        }
        else{
            count++;
        }
    }
    m= max(m, count);

    cout << m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;

mat t;
vll v;
lli c;
string s;
lli x;

void insert(lli x,lli i){
    if(x < v[i]){
        if(t[i][0] >= 0) insert(x,t[i][0]);
        else t[i][0] = c;
    }else{
        if(t[i][1] >= 0) insert(x,t[i][1]);
        else t[i][1] = c;
    }
}

void inorder(lli i){
    if(t[i][0] >= 0) inorder(t[i][0]);
    cout << " " << v[i];
    if(t[i][1] >= 0) inorder(t[i][1]);
}

void preorder(lli i){
    cout << " " << v[i];
    if(t[i][0] >= 0) preorder(t[i][0]);
    if(t[i][1] >= 0) preorder(t[i][1]);
}

int main(){
    cin >> n;
    t = mat(n,vll(2,-1));
    v = vll(n);
    for(lli i = 0;i < n;i++){
        cin >> s;
        if(s == "insert"){
            cin >> x;
            v[c] = x;
            if(i) insert(x,0);
            c++;
        }else if(s == "print"){
            inorder(0);cout << endl;
            preorder(0);cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 33852
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    int n; cin >> n;
    int arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    int a = INT_MAX, ans = 0;
    for(int i=0; i<n; i++){
        if(a > arr[i]){
            a = arr[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)

const int maxn = 2e5 + 5;

int a[maxn];

int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL
	int n;
	scanf("%d", &n);
	int t;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &t);
		a[i - 1] = t - i;
	}

	sort(a, a + n);
	int val = a[n >> 1];

	unsigned long long sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += abs(a[i] - val);
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int cmpnum(const void * n1, const void * n2)
{
	if(*(int *)n1 >*(int *)n2)
	{
		return -1;
	}
	else if(*(int *)n1 < *(int *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
}
}

int main(void)
{
	int n,i;
	int a[200000]={0};
	int k;
	int score=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&k);
		a[i]=k;
	}
	
	qsort(a, sizeof(a)/ sizeof(a[0]),sizeof(int),cmpnum);
	
	for(i=0;i<n-1;i++){
		if(a[i]==a[i+1])
			score++;
	}
	
	if(score>0)
		printf("NO");
	else
		printf("YES");
	
	return 0;
}

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    x,y = map(int, input().split())

    ans = 0
    while x <= y:
        x *= 2
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		char[] ary = String.valueOf(n).toCharArray();
		int s = 0;
		for (char c : ary) {
			s += Character.getNumericValue(c);
		}
		System.out.println(n%s==0? "Yes":"No");
	}
}


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

typedef long long ll;

ll N;
typedef pair<ll, ll> Coord, RCoord;
set<Coord> Red, Blue;
set<RCoord> Pool;
ll R;

RCoord yx(Coord xy) { return RCoord(xy.second, xy.first); }
int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    Red.insert(Coord(a, b));
  }
  for (ll i = 0; i < N; ++i) {
    ll c, d;
    cin >> c >> d;
    Blue.insert(Coord(c, d));
  }
  for (Coord blue : Blue) {
    while (!Red.empty() && *Red.begin() < blue) {
      auto it = Red.begin();
      Pool.insert(yx(*it));
      Red.erase(it);
    }
    auto it = Pool.lower_bound(yx(blue));
    if (it != Pool.begin()) {
      --it;
      Pool.erase(it);
      ++R;
    }
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;


  vector<int> ans(s.size());

  for(int j=0;j<2;j++){  
    int t=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='R'){
      t++;
    }
    else{
      ans[i]+=t/2;
      ans[i-1]+=(t+1)/2;
      t=0;
    }
  }

        
        
    reverse(s.begin(),s.end());
    reverse(ans.begin(),ans.end());
    
    for(int y=0;y<s.size();y++){
      if(s[y]=='R'){
        s[y]='L';
      }
      else{
        s[y]='R';
      }
    }
  }
  for(int i=0;i<s.size();i++){
    cout<<ans[i]<<" ";
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
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;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>
#define init(type,var) type var;cin>>var;
#define vinit(vtype,var,n) vtype var(n);loop(i,0,n)cin>>var[i];

const ull MOD = 1000000007ULL;
const ull INF = (ull)(-1LL);

int main(void){
	init(ull, n);
	vinit(vector<string>, s, n);
	loop(i, 0, s.size()){
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	ull count = 0;
	for (int i = 0; i < s.size();){
		ull _c;
		for (_c = 1; i + _c < s.size() && s[i + _c] == s[i]; _c++);
		count += (_c * (_c - 1) / 2);
		i += _c;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        long ans = 0;
        for(int i = 1; i <= n; i++){
            if(i%3 == 0 || i%5 == 0) continue;
            ans += i;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27084