akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

X, A = LI()
print(0 if (X<A) else 10)


Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        cout << "Possible";
    else
        cout << "Impossible";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N-1):
  if A[i] == A[i+1]-1:
    B.append(C[A[i]-1])
    
print(sum(B))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;

void solve();

const int N = 2e5 + 10;

int main() {
    fast_cin();

    int t=1;
    // cin >> t;
    while(t--) {
        solve();
    }
}

void solve() {
    int n;
    cin >> n;
    int a[N];
    for (int i=1; i <= n; i++) { 
        cin >> a[i];
    }

    int curr = 1;
    for (int i=1; i <= n; i++) {
        if (a[i] == curr) {
            curr++;
        }
    }
    
    cout << (curr != 1 ? n-curr+1 : -1) << '\n';
}


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

int main(void){
  int N;
  cin >> N;
  lint A[N];
  rep(i,N) cin >> A[i];
  lint ans=LINF;
  lint snuke=0,arai=accumulate(A,A+N,0LL);
  rep(i,N-1){
    snuke+=A[i];
    arai-=A[i];
    ans=min(ans,llabs(snuke-arai));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve()
{
    string s; cin >> s;
    int n = s.size();
    int m = 2019;

    reverse(s.begin(),s.end());

    int x = 1 , total = 0 ;
    vector<int> val(2019,0) ;
    val[total] = 1 ;
    ll ans = 0 ;
    
    loop(i,0,n)
    {
        total += (s[i] - '0')*x ;
        total %= m ;
        val[total]++;
        x = 10*x%m ;
    }
    loop(j,0,2019) ans += ( val[j] - 1)*val[j]/2 ;
    cout << ans << endl;

}

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

Measured memory_bytes: 3728
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
exppression = stdin.readline().split()
stack = []
while exppression:
    token = exppression.pop(0)
    if token.isdigit():
        stack.append(int(token))
    elif token == '+':
        n = stack.pop()
        stack[-1] += n
    elif token == '-':
        n = stack.pop()
        stack[-1] -= n
    else:
        n = stack.pop()
        stack[-1] *= n
print(stack[-1])

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

int dp[100005];

int dfs(int x, vector<int> e[])
{
    if(dp[x]!=-1)
        return dp[x];
    int ans=0;
    for(int i=0;i<e[x].size();i++)
    {
        ans=max(ans,dfs(e[x][i],e)+1);
    }
    dp[x]=ans;
    return dp[x];
}

void solve()
{
    int n,m,ans=0;
    cin>>n>>m;
    vector<int> e[n+1];
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        e[x].push_back(y);
    }
    for(int i=1;i<=n;i++)dp[i]=-1;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dfs(i,e));
    }
    cout<<ans<<"\n";
}

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

Measured memory_bytes: 8192
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		int min = a[0];
		int max = a[a.length - 1];
		if (max - min > 1) {
			out.println("No");
		} else {
			if (max - min == 0) {
				if (n - 1 == max || max <= n / 2) out.println("Yes");
				else out.println("No");
			} else {
				int count = 1;
				for (int i = 0; i < a.length - 1; i++) {
					if (a[i] == a[i + 1]) count++;
					else break;
				}
				int cmax = max - 1;
				int cmin = Math.max(1, cmax - (n - cmax - 2));
				if (cmin <= count && count <= cmax) out.println("Yes");
				else out.println("No");
			}
		}

		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) { return false; }
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long nextLong() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 24236
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<9;i++){
    if(N%(9-i)==0&&N/(9-i)<10){
      printf("Yes");
      break;
    }
    if(i==8) printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.Map as M

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve s t = if uniq s t && uniq t s then "Yes" else "No"

uniq s t = case foldr op (Just M.empty) (zip s t) of
              Nothing -> False
              Just _ -> True
  where
    op (c1,c2) Nothing = Nothing
    op (c1,c2) (Just mp) =
      case M.lookup c1 mp of
        Nothing -> Just (M.insert c1 c2 mp)
        Just c0 -> if c0 == c2 then Just mp else Nothing


main = do
  conts <- B.getContents
  let [s,t] = B.words conts
      s1 = B.unpack s
      t1 = B.unpack t
      ans = solve s1 t1
  putStrLn ans


Measured memory_bytes: 24828
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <functional>
#include <map>
#include <set>
using namespace std;
 
 
 
int main() 
{
    int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int total = 0;
  for (int i = 0; i < n; i++) {
      cin >> a[i];
      total += a[i];
  }
 
  sort(a.begin(), a.end());
  int min = total / (4*m) + (total % (4*m) ? 1 : 0);
  for (int i = 0; i < m; i++) {
      if (a[n - i - 1] < min) {
          cout << "No";
          return 0;
      }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        scanner.close();

        if (B % A == 0) {
            System.out.println(A + B);
        } else {
            System.out.println(B - A);
        }
    }
}


Measured memory_bytes: 23508
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

	  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> cnt(MAX);
  for (int i = 0; i < n; i++) {
    cnt[a[i]] += 1;
  }
  vector<bool> good(MAX, true);
  int ans = 0;
  for (int i = 1; i < MAX; i++) {
    if (cnt[i] != 0) {
      for (int j = i + i; j < MAX; j += i) {
        good[j] = false;
      }
    }
  }
  for (int i = 0; i < MAX; i++) {
    if (good[i] && cnt[i] == 1) {
      ++ans;
    }
  }
  cout << ans << '\n';

 eNd();
  return 0;
 
}


Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
  if(c=="a") cout << "vowel" << endl;
  else if(c=="i") cout << "vowel" << endl;
  else if(c=="u") cout << "vowel" << endl;
  else if(c=="e") cout << "vowel" << endl;
  else if(c=="o") cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) break;
			for (int i = 1; i <= H; i ++) {
				if (i == 1 || i == H) for (int j = 1; j <= W; j ++) System.out.print("#");
				else {
					System.out.print("#");
					for (int k = 2; k <= W - 1; k ++) System.out.print(".");
					System.out.print("#");
				}	
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 36980
#include <stdio.h>

int main(void)
{
  int x = 0;
  int y = 0;
  int i = 0;
  
  do {
    scanf("%d %d", &x, &y);
    if(x == 0 && y == 0)
      break;
    if(x < y)
      printf("%d %d\n", x, y);
    else
      printf("%d %d\n", y, x);
    } while(1);

  
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
    ll n;
    vector<string> s;
    cin >> n;
    rep(i,n) {
        string a;
        cin >> a;
        s.push_back(a);
    } 
    sort(s.begin(),s.end());
    ll begin = 0, ans = n;
    for(int i=1;i<n;i++){
        if(begin == i) continue;
        if(s[begin] == s[i]) ans--;
        else begin = i;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N,K,d,t;
    set<int> s;
    cin>>N>>K;
    for(int i=1;i<=N;i++)
        s.insert(i);
    for(int i=0;i<K;i++)
    {
        cin>>d;
        for(int j=0;j<d;j++)
        {
            cin>>t;
            s.erase(t);
        }

    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 3520
N, x = map(int, input().split())
srt_a = sorted(map(int, input().split()))

sum_a = sum(srt_a)
if sum_a == x:
    # ちょうど全員喜ぶ
    ans = N
elif sum_a < x:
    # N-1 人喜ぶ。ある一人に残りの飴を全部押し付ける
    ans = N - 1
else:
    # 喜ぶ数の少ない順に配れば、喜ぶ人数が最大化される
    cnt = 0
    while True:
        a = srt_a[cnt]
        if x >= a:
            x -= a
            cnt += 1
        else:
            break
    ans = cnt

print(ans)

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

int main()
{
   int a,b,c;
   scanf("%d%d%d",&a,&b,&c);
   if(a*c<=b)printf("%d\n",c);
   else
   {
       printf("%d\n",(int)(b/a));
   }
    return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

int a[300005]={0},pref[300005]={0};

signed main()
{
    priority_queue< int,vector<int>, greater <int> > f;
    priority_queue<int> s;
    int n;  cin>>n;
    int N=n*3,fsum=0 ,ssum=0;
    for (int i=1;i<=N;i++) {
        cin>>a[i];
        if (i<=n){
            fsum += a[i];
            f.push(a[i]);
        }
        if (i>2*n){
            ssum += a[i];
            s.push(a[i]);
        }
    }
    pref[1] = fsum;
    pref[n+1] = -ssum;
    for (int i=1;i<=n;i++){
        fsum += a[n+i];
        ssum += a[2*n-i+1];
        f.push(a[n+i]);
        s.push(a[2*n-i+1]);
        int mn=f.top(),mx=s.top();
        f.pop(); s.pop();
        fsum -= mn; ssum -= mx;
        pref[i+1] += fsum;
        pref[n-i+1] -= ssum;
    }
    int ans=INT64_MIN;
    for (int i=1;i<=n+1;i++)
        ans = max(ans,pref[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8136
h,w = map(int,input().split())
maze = [input() for _ in range(h)]

dph = [[0 for _ in range(w)] for _ in range(h)]
dpw = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
  for j in range(w):
    if maze[i][j] == '#':
      continue
    if dpw[i][j] != 0:
      continue
    k = j
    count = 0
    while k< w:
      
      if maze[i][k] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dpw[i][l] = count
      
for i in range(w):
  for j in range(h):
    if maze[j][i] == '#':
      continue
    if dph[j][i] != 0:
      continue
    k = j
    count = 0
    while k< h:
      
      if maze[k][i] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dph[l][i] = count


ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, dpw[i][j] + dph[i][j])
print(ans-1)

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

int main() {
  
  int x;
  cin >> x;
  
  if (x >= 400 && x <= 599) cout << 8;
  if (x >= 600 && x <= 799) cout << 7;
  if (x >= 800 && x <= 999) cout << 6;
  if (x >= 1000 && x <= 1199) cout << 5;
  if (x >= 1200 && x <= 1399) cout << 4;
  if (x >= 1400 && x <= 1599) cout << 3;
  if (x >= 1600 && x <= 1799) cout << 2;
  if (x >= 1800 && x <= 1999) cout << 1;
  
}


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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

string S;

int main(void)
{
    cin >> S;
    int N = S.size();

    for (int i = 0; i < N / 2; ++i) {
        if (S[i] != S[N - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    int n2 = (N - 1) / 2;
    for (int i = 0; i < n2 / 2; ++i) {
        if (S[i] != S[n2 - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    int n3 = (N + 3) / 2;
    int c = (n3 + N) / 2;
    for (int i = 0; i < c - n3; ++i) {
        if (S[n3 - 1 + i] != S[N - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

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

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

int main(){
	
	long long int x,y,z,hp,hp1,left;
	cin>>x;
	y=x/500;
	hp=y*1000;
	left=x%500;
	z=left/5;
	hp1=z*5;
	cout<<( hp + hp1 )<<endl;
	
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
S=0
for i in range(N):
	S=S+A[i]
min=S/(4*M)
count=0
for i in range(N):
	if A[i]>=min:
		count=count+1
if count>=M:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int l,m[12],n[12];
	int i,sum;
	
	while(1)
	{
		scanf("%d",&l);
		
		if(l==0)
		{
			break;
		}
		for(i=0;i<12;i++)
		{
			scanf("%d %d",&m[i],&n[i]);
		}
		
		sum=0;
		
		for(i=0;sum<l;i++)
		{
			sum+=m[i]-n[i];
		}
		
		if(i==13)
		{
			printf("NA\n");
		}
		else
		{
			printf("%d\n",i);
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 612
N = int(input())

a = 0
b = 0

for i in range(2, 10):
    if N <= 9:
        print('Yes')
        b = 1
        break
    if N % i == 0:
        a = N / i
        if a <= 9:
            print('Yes')
            b = 1
            break

if b == 0:
    print('No')



Measured memory_bytes: 2940
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,m = (int(x) for x in input().split())
graph = [set() for _ in xrange(n)]
for _ in xrange(m):
    a,b = (int(x)-1 for x in input().split())
    graph[a].add(b)
    graph[b].add(a)

visited = [False for _ in xrange(n)]
ans = 0
for i in xrange(n):
    if visited[i]:
        continue
    
    stack = [i,]
    cnt = 1
    while stack:
        node = stack.pop()
        if visited[node]:
            continue
        visited[node] = True
        cnt += 1
        for next_node in graph[node]:
            stack.append(next_node)
    ans = max(cnt,ans)
print(ans-1)

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

int cmp(const void*a,const void*b){
	return *(int*)a-*(int*)b;
}
int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	int x[n];
	int i;
	for(i=0;i<n;i++)scanf("%d",&x[i]);
	int ans = 0;
	for(i=0;i<n;i++){
		if( (2*x[i])>abs(k-x[i])*2){
			ans += abs(k-x[i])*2;
		}else ans+= 2*x[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

long long c[100][100];

int main(){
  int n, m, l;
  scanf("%d%d%d", &n, &m, &l);

  int a[100][100];
  int b[100][100];

  int i,j,k;
  for(i = 0;i < n;i++){
    for(j = 0;j < m;j++){
      scanf("%d", &a[i][j]);
    }
  }

  for(i = 0;i < m;i++){
    for(j = 0;j < l;j++){
      scanf("%d", &b[i][j]);
    }
  }

  for (i = 0;i < n;i++){
    for(j = 0;j < l; j++){
      for(k = 0;k < m;k++){
	c[i][j] += a[i][k]*b[k][j];
      }
      printf("%lld", c[i][j]);
      if(l - j != 1)
	printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,x,y;
    int a[101]={},b[101]={},c=0,d=0;
    
    cin>>n>>m>>x>>y;
    
    for(int i=0;i<n;i++){
     cin>>a[i];
     if(a[0]!=a[i] && a[i]>c) c=a[i];
     else if(a[i]==a[0]) c=a[i];
    }
    
    for(int i=0;i<m;i++){
     cin>>b[i];
     if(b[0]!=b[i] && b[i]<d) d=b[i];
     else if(b[i]==b[0]) d=b[i];
    }
    
    
    if(c<d && c>x && d<y) cout<<"No War"<<endl;
    else cout<<"War"<<endl;

    return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextLong()
    val op = sc.next()
    val b = sc.nextLong()
    val out = op match {
      case "+" => a + b
      case "-" => a - b
    }
    println(out)
  }
}

Measured memory_bytes: 22340
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 100100;
ll A[MAX_N], B[MAX_N];
ll N, M;

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

ll all_lcm(){
    ll res = 1LL;
    for(int i = 0; i < N; ++i) res = res*B[i]/gcd(res,B[i]);
    return res;
}

int main()
{
    scanf("%lld %lld", &N, &M);
    for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);
    for(int i = 0; i < N; ++i) B[i] = A[i]/2LL;
    ll LCM1 = all_lcm();
    ll LCM2 = 2LL*LCM1;
    //printf("%lld %lld\n", LCM1, LCM2);
    for(int i = 0; i < N; ++i) if((LCM1/B[i])%2==0) { printf("0\n"); return 0;}
    if(LCM1 > M ) { printf("0\n"); return 0;}
    ll res = 1LL + (M - LCM1)/LCM2;
    printf("%lld\n", res);
    return 0;
}

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

int N, K, h[100000];
int dp[100000];


int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }

    for(int i = 1; i < N; i++){
        dp[i] = 1e9 + 1;
        for(int j = 1; i - j >= 0 && j <= K; j++){
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

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


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <map>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int N = 410;

struct Col{ 
	int c1, c2, c3, c4;
	bool operator < (const Col& S) const {
		if (c1 != S.c1) return c1 < S.c1;
		if (c2 != S.c2) return c2 < S.c2;
		if (c3 != S.c3) return c3 < S.c3;
		return c4 < S.c4;
	}
	bool operator == (const Col& S) {
		return c1 == S.c1 && c2 == S.c2 && c3 == S.c3 && c4 == S.c4;	
	}
	
} c[N];
map<Col, int> m;

void add(Col x, int v)
{
	Rep(i, 4){
		m[x] += v;
		int tmp = x.c1;
		x.c1 = x.c2, x.c2 = x.c3, x.c3 = x.c4, x.c4 = tmp;
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	Rep(i, n) {
		scanf("%d%d%d%d", &c[i].c1, &c[i].c2, &c[i].c3, &c[i].c4);
		m[(Col){c[i].c1, c[i].c2, c[i].c3, c[i].c4}] ++;
		m[(Col){c[i].c2, c[i].c3, c[i].c4, c[i].c1}] ++;
		m[(Col){c[i].c3, c[i].c4, c[i].c1, c[i].c2}] ++;
		m[(Col){c[i].c4, c[i].c1, c[i].c2, c[i].c3}] ++;
	}
	LL ans = 0;
	Rep(i, n) for (int j = i + 1; j <= n; j ++) {
		int ti = m[c[i]], tj = m[c[j]];
		if (ti) add(c[i], -1); if (tj) add(c[j], -1);
		Col tmp = (Col){c[j].c4, c[j].c3, c[j].c2, c[j].c1};
		Rep(k, 4) {
			LL tans = 1;
			int mt1, mt2, mt3, mt4;
			Col t1 = (Col){tmp.c1, tmp.c2, c[i].c2, c[i].c1};
			mt1 = m[t1], tans *= mt1;
			if (mt1) add(t1, -1);
			Col t2 = (Col){tmp.c2, tmp.c3, c[i].c3, c[i].c2};
			mt2 = m[t2], tans *= mt2;
			if (mt2) add(t2, -1);
			Col t3 = (Col){tmp.c3, tmp.c4, c[i].c4, c[i].c3};
			mt3 = m[t3], tans *= mt3;
			if (mt3) add(t3, -1);
			Col t4 = (Col){tmp.c4, tmp.c1, c[i].c1, c[i].c4};
			tans *= m[t4];
			if (mt1) add(t1, 1);
			if (mt2) add(t2, 1);
			if (mt3) add(t3, 1);
			
			int ttmp = tmp.c1;
			tmp.c1 = tmp.c2, tmp.c2 = tmp.c3, tmp.c3 = tmp.c4, tmp.c4 = ttmp;
			ans += tans;
		//	printf("%d %d %d %d %d\n", i, j, k, tans);
		}
		if (ti) add(c[i], 1); if (tj) add(c[j], 1);
	}
	
	printf("%lld\n", ans / 3);
	
	return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
ll n,m;
string s,s1,s2;
priority_queue <long long int> pq;
map<ll, char> mp;
vector<pair<int,int> > inc;
vector<pair<int,int> > de;
ll arr[300005],barr[300005];
//EG
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	int i,j,k,z,ans=0,c=0,x=0,y=0;
	
	cin>>n>>k;
	rep(i,0,n){
		cin>>arr[i];
		if(arr[i]>=k)
		c++;
	}
	cout<<c;
 	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll a, b;
    cin >> a >> b;
    if(a==2 || b==2) {
        pNo
        return 0;
    }else {
        pYe
    }
    
    
}


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

#define ll long long
#define vt vector
#define pb push_back
#define sz(x) (int)(x).size()

int main(){
  int n;cin>>n;
  vt<vt<int>> A(n,vt<int>(3));
  vt<vt<int>> dp(n,vt<int>(3));

  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++) cin>>A[i][j];

  for(int j=0;j<3;j++) dp[0][j]=A[0][j];
  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
      int a=(j+1)%3,b=(j+2)%3;
      dp[i][j]=A[i][j]+max(dp[i-1][a],dp[i-1][b]);
    }
  }

  int ans=dp[n-1][0];
  for(int j=0;j<3;j++) ans=max(ans,dp[n-1][j]);
  cout<<ans<<endl;
}


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

#include <iostream>
#include <string>

using namespace std;

class AProduct {
public:
    void solve(std::istream& in, std::ostream& out) {
        int a, b;
        in >> a >> b;

        string ret;
        if ((a * b) % 2 == 0) {
            ret = "Even";
        } else {
            ret = "Odd";
        }

        out << ret;
    }
};


int main() {
	AProduct solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1]%MOD * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] %MOD * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		if (q < 0 || p < q) return (0LL);
		return (fact[p]%MOD * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;



	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long N;int K;
cin >> N;
cin >> K;
long long s = 0;
for (int i = K ; i <= N +1; ++i){
s += i*(N -i +1) +1;}
  s = s % 1000000007;
  cout << s << endl;
}


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




int main()
{
	int N;
	long long X;
	cin >> N >> X;
	
	long long a[51];
	a[0] = 1;

	for (int i = 1; i < 51; i++)
	{
		a[i] = 2 * a[i - 1] + 3;
	}

	long long p[51];
	p[0] = 1;

	for (int i = 1; i < 51; i++)
	{
		p[i] = 2 * p[i - 1] + 1;
	}

	long long ans = 0;

	for (int i = N; i >= 0; i--)
	{
		if (i == 0)
		{
			if (X == 0)
			{
				break;
			}
			else
			{
				ans += 1;
				break;
			}
		}
		else
		{
			if (X == 0)
			{
				break;
			}

			else if (1 <= X && X <= 1 + a[i - 1])
			{
				X--;
				continue;
			}

			else if (X == 2 + a[i - 1])
			{
				ans += p[i - 1] + 1;
				break;
			}

			else if (3 + a[i - 1] <= X && X <= 2 * a[i - 1] + 2)
			{
				ans += p[i - 1] + 1;
				X = X - a[i - 1] - 2;
				continue;
			}

			else
			{
				ans += 2 * p[i - 1] + 1;
				break;
			}
		}
	}

	cout << ans;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Segment_Sum {
private:
  lint n;
  vector<lint> node;
public:
  Segment_Sum(lint N) {
    lint sz = N;
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1, 0);
  }
  void update(lint x) {
    x += (n - 1);
    node[x] += 1;
    while(x > 0) {
      x = (x - 1) / 2;
      node[x] = node[2*x+1] + node[2*x+2];
    }
  }
  lint getsum(int a, int b, int k=0, int l=0, int r=-1) {
    if(r < 0) r = n;
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return node[k];
    lint vl = getsum(a, b, 2*k+1, l, (l+r)/2);
    lint vr = getsum(a, b, 2*k+2, (l+r)/2, r);
    return vl + vr;
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  lint l = 0;
  lint r = 1<<30;
  lint m = 0;
  if(N == 1) {
    cout << A[0] << endl;
    return 0;
  }
  while(l < r) {
    m = (l + r) / 2;
    vector<lint> S(N+1);
    REP(i, N) {
      if(A[i] >= m) {
        S[i+1] = 1;
      } else {
        S[i+1] = -1;
      }
    }
    FOR(i, 1, N+1) {
        S[i] += S[i-1];
    }
    lint ans = 0;
    Segment_Sum seg(2*N+10);
    REP(i, N+1) {
      ans += seg.getsum(0, N+1+S[i]+1);
      seg.update(N+1+S[i]);
    }
    //cout << l << " " << r << " " << ans << endl;
    lint target = N*(N+1)/2/2;
    if(ans < target) {
      if(l == m) {
        r--; m--;
        break;
      } else {
        r=m;
      }
      
    } else {
      if(l == m) {
        break;
      } else {
        l=m;
      }
      
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 5896
a = gets.split(" ").map{|s|s.to_f}

d = a[0].to_i/a[1].to_i
r = a[0].to_i%a[1].to_i
f = (a[0]/a[1]).round 6

puts d.to_s+" "+r.to_s+" "+f.to_s

Measured memory_bytes: 6176
#include<iostream>
#define long long long
using namespace std;
long pow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return pow(x * x % m, n / 2, m);
  else
    return x * pow(x, n - 1, m) % m;
}

int main(){
  long n,k;
  cin>>n>>k;
  long ans,mod;
  ans=0;
  mod=1000000007;
  long a[k+1];
  for(long l=k; l>0; l--){
    long x=pow(k/l,n,mod);
    for (long d=2;d<k/l+1;d++){
      x-=a[d*l];
      x%=mod;
    }
    
    a[l]=x;

  }
  for (long i=1; i<k+1; i++){
    ans+=a[i]*i;
    ans%=mod;
  }

  cout<<ans%mod<<endl;
  
  return 0;
}



Measured memory_bytes: 4368
#include <stdio.h>
int main(){
	int N;
	int M;
	int a;
	scanf("%d",&N);
	scanf("%d",&M);
	int i;
	long long int yuka[100001];
	for(i=0;i<=N;i++){
		yuka[i]=1;
	}
	for(i=1;i<=M;i++){
		scanf("%d",&a);
		yuka[a]=0;
	}
	long long int dp[100001];
	dp[0]=1;
	dp[1]=yuka[1];
	for(i=2;i<=N;i++){
		dp[i]=(dp[i-2]*yuka[i-2]+dp[i-1]*yuka[i-1])%1000000007;
	}
	printf("%lld",dp[N]);
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int[] arr = new int[n];
		int[] ans = new int[n];

		for (int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(sc.next());
			ans[i] = i+1;
		}

		int count = 0;
		for (int i = 0; i < n; i++) {
			if(arr[i] != ans[i]) {
				count++;
			}
		}

		if(count == 0 || count == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#define inf 1e9
#define eps 1e-6
#define N 4010
#define mod 924844033
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;
}
ll f[N][N][2];
int n,k;
int ed[N],tot;
ll fac[N];
int vis[N][2];
int main()
{
	n=read(),k=read();
	fac[0]=1;
	for(register int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
	for(register int i=1;i<=n;i++)
	{
		for(register int j=0;j<=1;j++)
		{
			if(!vis[i][j])
			{
				for(register int now=i,p=j;now<=n;now+=k,p^=1)++tot,vis[now][p]=1;
				ed[tot]=1;
			}
		}
	}
//	cout<<ed[tot]<<endl;
	f[1][0][0]=1;
	for(register int i=1;i<=tot;i++)
	{
		for(register int j=0;j<=n;j++)
		{
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
			if(!ed[i])f[i+1][j+1][1]=f[i][j][0];
		}
	}
	ll ans=fac[n],c=-1;
	for(register int i=1;i<=n;i++)
	{
		ans=(ans+(f[tot][i][0]+f[tot][i][1])%mod*fac[n-i]%mod*c)%mod;
		c=-c;
	}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 144676
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(0);

void min_self(long long& a, long long b)
{
  a = min(a, b);
}

const long long inf = 1e9 + 5;

class gh{
public:
  long long val;
  long long wt;
};

pair<long long, long long> dp1[3005][3005], dp2[3005][3005];

int main()
{
    long long n, w;
    cin >> n >> w;
    w -= 1;


     gh P[n + 1];

     for (long long i = 1; i < n + 1; i++) {
        cin >> P[i].wt >> P[i].val;
     }








     for (long long i = 1; i < w + 1; i++) {
        for (long long j = 1; j < n + 1; j++) {

          dp1[i][j].second = dp1[i][j - 1].second;

          //if(i == 1 && j == 1) cout << dp1[i][j].second << " ";

          if(i - P[j].wt >= 0)
          dp1[i][j].second = max(dp1[i][j].second, P[j].val + dp1[i - P[j].wt][j - 1].second);

          //cout << P[j].val << " ";

          //if(i == 1 && j == 1) cout << i - P[j].wt << " ";

        }
     }



     long long ans = 0;

     ans = dp1[w][n].second ;

     //cout << ans << "\n";















     for (long long i = 1; i < w + 1; i++) {
        for (long long j = n; j >= 1; j--) {

          long long A = 0;
          long long B = 0;
          if(j + 1 <= n) {A = dp2[i][j + 1].second; }


          dp2[i][j].second = A;
          if(i - P[j].wt >= 0)
            {
                if(j + 1 <= n) B = dp2[i - P[j].wt][j + 1].second;
                dp2[i][j].second = max(dp2[i][j].second, P[j].val + B);
            }
        }
     }


     //cout << dp2[w][1].second << "\n";





     for (long long i = 1; i <= n; i++) {

       long long ans1 = P[i].val;


       for (long long j = 0; j <= w; j++) {
          long long temp = 0;
          if(i - 1 >= 0)
          temp = dp1[j][i - 1].second;
          long long temp1 = 0;
          if(i + 1 <= n)
          temp1 = dp2[w - j][i + 1].second;

          long long kl = ans1 + temp + temp1;
          ans = max(ans, kl);
       }






     }

     //return 0;

     cout << ans;



























}

// g++ -std=c++11


Measured memory_bytes: 282240
package main

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

type Bridge struct {
	a int
	b int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nIslands := scanInt(sc)
	nBridges := scanInt(sc)

	bridges := make([]Bridge, nBridges)

	for i := 0; i < nBridges; i++ {
		a, b := scanInt(sc), scanInt(sc)
		bridges[i] = Bridge{a, b}
	}

	// 島ごとに自分が所属するグループ (木) の代表を保持する。
	islands := make([]int, nIslands+1)

	// 各グループの島の数を保持する。行き来できる島のペア数を数えるのに必要。
	members := make([]int64, nIslands+1)

	// 初期状態はすべての島が独立したグループであり、メンバー数は1。
	for i := 1; i <= nIslands; i++ {
		islands[i] = i
		members[i] = 1
	}

	// connectedPairs[i]: i番目の橋まで崩落した時の、行き来できる島のペア数。
	// i==0 なら橋が1つも崩落していない状態のペア数。
	connectedPairs := make([]int64, nBridges+1)

	// 橋の崩落を逆からたどり、全ての島が孤立した状態から始める。
	// 1つずつ橋をつなげていき、行き来できるようになる島の数を数えていく。
	for i := nBridges - 1; i >= 0; i-- {
		bridge := bridges[i]

		ra := findRoot(islands, bridge.a)
		rb := findRoot(islands, bridge.b)

		// 既に同じグループの島同士がつながってもペア数は変わらない。
		if ra == rb {
			connectedPairs[i] = connectedPairs[i+1]
			continue
		}

		var main, sub int
		if members[ra] > members[rb] {
			main = ra
			sub = rb
		} else {
			main = rb
			sub = ra
		}

		islands[sub] = main

		// グループを結合すると、それぞれのメンバー同士の組み合わせ分ペア数が増える。
		// (https://www.youtube.com/watch?v=zV3Ul2pA2Fw)
		newConnectedPairs := members[main] * members[sub]
		connectedPairs[i] = connectedPairs[i+1] + newConnectedPairs
		members[main] += members[sub]
	}

	maxPairs := connectedPairs[0]
	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= nBridges; i++ {
		fmt.Fprintln(w, maxPairs-connectedPairs[i])
	}
	w.Flush()
}

func findRoot(islands []int, x int) int {
	if islands[x] == x {
		return x
	}
	root := findRoot(islands, islands[x])
	islands[x] = root
	return root
}

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


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
	int N = 0;
	while(cin >> N)
	{
		vector < int > v;
		v.resize(N+1);

		for(int i = 0; i <=N; ++i)
		{
			if(i >= 2)
			{
				v[i] = 1;
			} else {
				v[i] = 0;
			}
		}

		for(int i = 2; i <= sqrt((double)N); ++i)
		{
			for(int j = 0; i*(j+2) <= N; ++j)
			{
				v[i*(j+2)]=0;
			}
		}

		int count = 0;
		for(int i = 0; i <= N; ++i)
		{
			if(v[i]==1)
				count++;
		}

		cout << count << endl;

	}

	return 0;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll rd1=1LL*rand()*rand()*rand()*rand();
const int rd2=rand()*rand();
struct ll_hash{ll operator()(ll x)const{return x+rd1;}};
struct int_hash{int operator()(int x)const{return x+rd2;}};
typedef unordered_map<ll,ll,ll_hash> ll_hash_map;
typedef unordered_map<int,int,int_hash> int_hash_map;
typedef unordered_map<int,int,int_hash> :: iterator int_hash_map_iter;
typedef unordered_map<ll,ll,ll_hash> :: iterator ll_hash_map_iter;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef __int128 _ll;
#define mk make_pair
inline void Read(_ll &x) {
	int f=1;char c=getchar(); x = 0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>'/'&&c<':'){x=x*10+c-'0';c=getchar();}
	x*=f;
}
inline void _P(_ll ret) {
    if (ret<0){putchar('-');ret=-ret;}
    if (ret>=10){_P(ret/10);}
    putchar(ret % 10+'0');
}
void rd(int &x) {scanf("%d",&x);}
void rd(ll &x){scanf("%lld",&x);}
void rd(_ll &x){Read(x);}
void rd(char s[]) { scanf("%s",s);}
void rd(char &x) {scanf("%c", &x);}
void pf(int x) {printf("%d", x);}
void pf(ll x){printf("%lld", x);}
void pf(_ll x){_P(x);}
void pf(char s[]){ printf("%s", s);}
void pf(char s){ printf("%c",s);}
void pr(int x){pf(x); pf('\n');}
void pr(ll x){pf(x); pf('\n');}
void pr(_ll x){pf(x); pf('\n'); }
void pr(char x[]){pf(x); pf('\n');}
void pr(char x){pf(x); pf('\n');}
void pk(int x){pf(x);pf(' ');}
void pk(ll x){pf(x);pf(' ');}
void pk(_ll x){pf(x);pf(' '); }
void pk(char x[]){pf(x);pf(' ');}
void pk(char x){pf(x);pf(' ');}
const ll mod=1e9+7;
const int maxn=1000+5;
const int maxm=1e6;

ll qpow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans * a % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}
ll fac(int n) {
	ll ans = 1;
	for (int i = 1; i <= n; i++) ans = ans * i % mod;
	return ans;
}

ll C(int n, int m) {
	ll t1 = fac(n);
	ll t2 = fac(m);
	ll t3 = fac(n-m);
	return t1 * qpow(t2, mod - 2) % mod * qpow(t3, mod - 2) %  mod;
}

int main() {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << "0"<<endl; return 0;
	}
	int t1 = (x + y) / 3;
	int t2 = 2 * t1 + 1;
	if (x < t1 || x > t2 || y < t1 || y > t2) {
		cout << "0" << endl; return 0;
	}
	
	cout << C(t1, x - t1) << endl;
	return 0;
}
//c(2, 1);


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const int MOD = 998244353;
const ll INF = 1000000000000000010LL;


int n;
int a[maxN];
int b[maxN];
ll power(ll x,ll p)
{
	if(p == 0)
		return 1;
	ll t = power(x,p/2);
	t = t*t%MOD;
	if(p%2 == 1)
	{
		t = t*x%MOD;
	}
	return t;
}
int main() {	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(a[1] != 0)
	{
		puts("0");
		return 0;
	}
	int len = 0;
	for(int i=1;i<=n;i++)
	{
		b[a[i]] ++;
		len = max(len,a[i]);
	}
	if(b[0] > 1)
	{
		puts("0");
		return 0;
	}
	ll ans = 1;
	for(int i=2;i<=len;i++)
	{
		if(b[i] == 0)
		{
			ans = 0;
			break;
		}
		ans = power(b[i-1],b[i]) * ans%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
A,B,C=map(int,input().split())
K=int(input())
cnt=0
while A>=B and cnt<K:
  B=2*B
  cnt+=1

while B>=C and cnt<K:
  C=2*C
  cnt+=1

if A<B<C:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184