akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

int main() {
    char b;cin>>b;
    if(b == 'A') cout << 'T';
    else if(b == 'T') cout << 'A';
    else if(b == 'G') cout << 'C';
    else cout << 'G';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), D = sc.nextInt(), X = sc.nextInt();
		int A[] = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			for (int j = 1; j <= D; j += A[i]) {
				sum++;
			}
		}
		sc.close();
		System.out.println(sum + X);
	}
}


Measured memory_bytes: 21844
# coding: utf-8
import sys
import copy


# 標準入力
n = int(sys.stdin.readline().strip())
xArray = list(map(int, sys.stdin.readline().strip().split(" ")))

result = []

sortedArray = sorted(xArray)


# 中央値を算出する
for i in range(n):
    middle = sortedArray[int((n / 2) - 1)]
    if (middle >= xArray[i]):
        result.append(sortedArray[int(n / 2)])
    else:
        result.append(middle)


# 標準出力
print('\n'.join(map(str, result)))


Measured memory_bytes: 32276
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    rFor(i,n) for(int i=n-1;i>=0;i--)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    min3(a,b,c)     min(a,min(b,c))
#define    max3(a,b,c)     max(a,max(b,c))
#define    min4(a,b,c,d)   min(min(a,b),min(c,d))
#define    max4(a,b,c,d)   max(max(a,b),max(c,d))
#define    Max(a)  *max_element(a,a+sizeof(a)/sizeof(a[0]))
#define    Min(a)  *min_element(a,a+sizeof(a)/sizeof(a[0]))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    //test
    {
        ll n,c=0;
        cin>>n;
        ll a[n];
        For(i,n)cin>>a[i];
        for(int i=0;i<n-1;i++)
        {
            if(a[i]>a[i+1]){
                c+=a[i]-a[i+1];
                a[i+1]=a[i];
            }
        }
        cout<<c;
    }
    
End;
}


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

bool solve();

int main()
{
	if (solve())
		printf("first\n");
	else
		printf("second\n");

	return 0;
}

bool solve()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		if (a & 1) return true;
	}
	return false;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int A = 0;
  int B = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      A += vec.at(i);
    } else {
      B += vec.at(i);
    }
  }
  cout << A - B << endl;
}


Measured memory_bytes: 256
n = int(input())
res = ""
cnt = 0
div = 0
if n == 0:
    print(0)
else:
    while n != 0:
        div = n % 2**(cnt+1)
        div = 1 if div > 0 else 0
        res = str(div) + res
        if div > 0:
            n -= (-2) ** cnt
        cnt += 1
    print(res)

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;
bool distribute(int& a,int& b,int& c){
    if(a%2==0&&b%2==0&&c%2==0){
        int _a=b/2+c/2;
        int _b=a/2+c/2;
        int _c=a/2+b/2;
        a=_a;
        b=_b;
        c=_c;
        return true;
    }
    else{
        return false;
    }
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,c;
cin>>a>>b>>c;
int ans=0;
while(distribute(a,b,c)){
    ans++;
    if(a==b&&b==c){
        ans=-1;
        break;
    }
}
cout<<ans<<endl;
return 0;
}

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

int main()
{
  int n;
  while(scanf("%d",&n)==1){
      if(n==0){
          break;
      }
      else{
          int a[1010];
          for(int i=0;i<n;i++){
              scanf("%d",&a[i]);

          }
          int step = 10000000;
          for(int i=0;i<n-1;i++){
              for(int j=i+1;j<n;j++){
                  if(abs(a[i]-a[j])<step){
                      step = abs(a[i]-a[j]);
                  }
              }
          }
          printf("%d\n",step);

      }

  }


    return 0;
}


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

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

using namespace std;

const int MAX_V = 50 * 50 * 30;
const int IINF = INT_MAX;

struct Edge { int src,dst; };
vector<Edge> G[MAX_V];
vector<int> computer;
int n,V,mat[61][61];

void dfs(int cur,int prev,int depth,vector<int> &mindist){

  rep(i,computer.size()) {
    if( computer[i] == -1 ) break;
    assert( i < mindist.size() );
    if( cur == computer[i] ) { assert( mindist[i] == IINF); mindist[i] = depth; }
  }

  rep(i,G[cur].size()){
    int next = G[cur][i].dst;
    if( next == prev ) continue;
    dfs(next,cur,depth+1,mindist);
  }

}

void compute(){
  computer.clear();
  computer.resize(n,-1);
  computer[0] = 0;
  V = 1;
  REP(i,1,n) {
    bool update = false; // for debug
    rep(candidate,V) {
      vector<int> mindist(i,IINF);
      dfs(candidate,-1,0,mindist);
      assert( mindist[0] != IINF );
      int add_length = -1;
      rep(j,i){
        int length = mat[i][j] - mindist[j];
        if( length <= 0 ) { add_length = -1; break; }
        if( add_length == -1 ) add_length = length;
        else if( add_length != length ) { add_length = -1; break; }
      }
      if( add_length != -1 ) {
        // add_length ????????????????????????
        // ????????????????????????????????? i ?????????????????\??????
        int prev = candidate;
        rep(k,add_length){
          G[prev].push_back((Edge){prev,V});
          G[V].push_back((Edge){V,prev});
          prev = V;
          ++V;
        }
        computer[i] = V-1;
        update = true;
        break;
      }
    }
    assert( update );
  }
  set<int> S;
  rep(i,n) S.insert(computer[i]);
  vector<int> answer;
  rep(i,V) if( !S.count(i) ) answer.push_back(G[i].size());
  sort(answer.begin(),answer.end());
  rep(i,answer.size()){
    if( i ) printf(" ");
    printf("%d",answer[i]);
  } puts("");
}

int main(){
  while( scanf("%d",&n), n ){
    rep(i,MAX_V) G[i].clear();
    rep(i,n) rep(j,n) scanf("%d",&mat[i][j]);
    compute();
  }
  return 0;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define int long long int
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int32_t main(){
	FIO
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]=='2'||s[n-1]=='9'||s[n-1]=='7'||s[n-1]=='5'||s[n-1]=='4')cout<<"hon";
	else if(s[n-1]=='0'||s[n-1]=='1'||s[n-1]=='6'||s[n-1]=='8')cout<<"pon";
	else cout<<"bon";
	
	return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=2e5+1e2;
const int N=2e5;
const int modd=1e9+7;
int n,m,r,c;
int Ans;
int fac[maxn],inv[maxn];

inline void file() {
	freopen("ARC058D.in","r",stdin);
	freopen("ARC058D.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline int quick(int a,int b) {
	int s=1;
	while (b) {
		if (b%2==1) s=1ll*s*a%modd;
		a=1ll*a*a%modd; b/=2;
	}
	return s;
}

inline int C(int n,int m) {
	if (n<m) return 0;
	return 1ll*fac[n]*inv[m]%modd*inv[n-m]%modd;
}

inline void Add(int &a,int b) {
	a+=b;
	if (a>=modd) a-=modd;
}

inline void init() {
	fac[0]=inv[0]=1;
	For (i,1,N) fac[i]=1ll*fac[i-1]*i%modd;
	inv[N]=quick(fac[N],modd-2);
	Forr (i,N-1,1) inv[i]=1ll*inv[i+1]*(i+1)%modd;
}

int main() {
//	file();
	init();
	n=read(); m=read(); r=read(); c=read();
	For (i,1,n-r) Add(Ans,1ll*C(i+c-2,i-1)*C((n-i+1)+(m-c)-2,m-c-1)%modd);
	printf("%d",Ans);
	return 0;
}

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

#define MAX_N (100)
#define SIZE_BUF (30)

int main(int argc, char *argv[]) {
  // read inputs
  int n;
  char as[MAX_N + 1], bs[MAX_N + 1], cs[MAX_N + 1], buf[SIZE_BUF];
  scanf("%d", &n);
  fgets(buf, SIZE_BUF, stdin);
  scanf("%s", as);
  fgets(buf, SIZE_BUF, stdin);
  scanf("%s", bs);
  fgets(buf, SIZE_BUF, stdin);
  scanf("%s", cs);
  fgets(buf, SIZE_BUF, stdin);

  // solve
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    const char a = as[i], b = bs[i], c = cs[i];
    if (a == b && b == c) {
      ;
    } else if (a == b || b == c || c == a) {
      cnt++;
    } else {
      cnt += 2;
    }
  }
  printf("%d\n", cnt);
  
  return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

int main(){
  string pass;
  while(cin >> pass){
    int flag = 0;
    
    if(pass.size() >= 6) flag |= 1;

    for(int i=0;i<pass.size();i++){
      if(isdigit(pass[i])) flag |= (1<<1);
      if('A' <= pass[i] && pass[i] <= 'Z') flag |= (1<<2);
      if('a' <= pass[i] && pass[i] <= 'z') flag |= (1<<3);
    }

    printf("%s\n",flag == (1<<4)-1 ? "VALID" : "INVALID");
  }
}

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

int main()
{
    int n;
    cin >> n;
    int m = n;
    int sum = 0;
    while (n > 0)
    {
        sum += n - 10 * (n / 10);
        n /= 10;
    }
    if (m % sum == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        const int Four = 4;
        const int Seven = 7;
        static int N;
        static bool Ok;
        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());

            // 2で100ドルだから全パターン網羅で行けそう
            Dfs(0, 0);

            Console.WriteLine(Ok ? "Yes" : "No");
        }

        static void Dfs(int f, int s)
        {
            if (Four * f + Seven * s > N || Ok) return;
            if (Four * f + Seven * s == N)
            {
                Ok = true;
                return;
            }

            Dfs(f + 1, s);
            Dfs(f, s + 1);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int k;
  int n;
  cin >> k >> n;
  int a[n];
  vector<int> dis(n);
  rep(i,n){
    cin >> a[i];
    if(i>0){
      dis[i-1]=abs(a[i-1]-a[i]);
    }
  }
  if(a[0]!=0){
    dis[n-1]=abs((k+a[0])-a[n-1]);
  }
  else{
    dis[n-1]=abs(k-a[n-1]);
  }

  std::vector<int>::iterator maxIt = std::max_element(dis.begin(),dis.end());
  size_t maxIndex = std::distance(dis.begin(), maxIt);
  if(maxIndex==0){
    cout <<abs(a[n-1]-a[maxIndex])<<endl; 
    return 0;
  }
  if(maxIndex==n-1){
    cout <<abs(a[maxIndex]-a[0])<<endl;
    return 0;
  }
  int ans =0;
  ans = a[maxIndex] + (k-a[maxIndex+1]);
  cout << ans<< endl;
  return 0;
}

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

using namespace std;

int main() {
    int N, H, W;
    vector<int> a, b;
    cin >> N >> H >> W;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        a.push_back(x);
        if (x >= H && y >= W) b.push_back(-1);
    }
    cout << b.size() << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP1_6_A
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            string[] x = Console.ReadLine().Split(' ');
            
            for (int i = n - 1; i >= 0; i --)
            {
                var j = int.Parse(x[i]);
                if (i == 0) Console.Write(j);
                else Console.Write("{0} ", j);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 17984
def main():
    INF = 10 ** 15
    N = int(input())
    A = list(map(int, input().split(' ')))
    cumsum = [0 for _ in range(N)]
    cumsum[0] = A[0]
    for i in range(1, N):
        cumsum[i] = A[i] + cumsum[i - 1]
    dp = [[0 for _ in range(N)] for _ in range(N)]

    def solve(left, right):
        if left == right:
            return 0
        ret = dp[left][right]
        if ret > 0:
            return ret
        ret = INF
        for mid in range(left, right):
            ret = min([
                ret,
                solve(left, mid) + solve(mid + 1, right)
            ])
        ret += cumsum[right] - (cumsum[left - 1] if left > 0 else 0)
        dp[left][right] = ret
        return ret

    print(solve(0, N - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 45788
#include<stdio.h>
#include<string.h>
char before , now;
char a[4][15];
int len[4];
bool ans = true;
int main(){
	scanf("%s",a[1]);
	len[1] = strlen(a[1]);
	before = a[1][len[1] - 1]; 
	for(int i = 2; i <= 3 ; i++)
	{
		scanf("%s",a[i]);
		len[i] = strlen(a[i]);

		now = a[i][0];
		if(now != before)
			ans = false;
		before = a[i][len[i] - 1]; 
		
	}
	if(ans)
		printf("YES");
	else
		printf("NO");
}

Measured memory_bytes: 128
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
ll a[1000000];
int main()
{
    for(ll i=1;i<=100;i++)
    {
        for(ll j=1;j<=100;j++)
        {
            for(ll k=1;k<=100;k++)
            {
                ll s=i*i+j*j+k*k+i*j+j*k+k*i;
                a[s]++;
            }
        }
    }
    ll n;
    sl(n);
    for(ll i=1;i<=n;i++)
    {
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4148
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val _, x :: xs = sc.next().toList
  val (_, compressed) = xs.foldLeft((x, List(x))) {
    case ((before, acc), char) =>
      if (before == char) before -> acc else char -> (char :: acc)
  }
  println(compressed.length)
}


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

int main()
{
        long long int n;
        cin >> n;
        long long int rmax = 1;
        for (long long int r = 1; r <= sqrt(n); ++r)
        {
                if (n % r == 0)
                        rmax = r;
        }
        cout << rmax + n / rmax - 2 << endl;
}


Measured memory_bytes: 256
using System;

namespace ALDS1
{
    class Program
    {
        static void Main()
        {
            var l = int.Parse(Console.ReadLine()) - 1;
            var min = int.Parse(Console.ReadLine());
            var max = -999999999;
            for (int i = 0; i < l; i++)
            {
                var a = int.Parse(Console.ReadLine());
                var b = a - min;
                if (b > max) max = b;
                if (a < min) min = a;
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 9268
/*
AizuOnline A0031
Weight
*/
#include <stdio.h>


main()
{
  int weight;
  int fundou;
  int flag;
  
  while(EOF !=scanf("%d",&weight))
    {
      flag = 0;
      for(fundou=1;fundou <= 512;fundou <<= 1)
      { if(weight & fundou)
        {
          if(flag)
            printf(" ");
          printf("%d",fundou);
          flag = 1;
        }
      }
        printf("\n");
    }

return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    ll ansN=1;
    ll ansM=1;
    for(int i=M; i>0; i--){
        ansM=ansM%MOD*i;
    }
    for(int i=N; i>0; i--){
        ansN=ansN%MOD*i;
    }
    if(abs((N-M))<2 && N!=M){
       cout << ansN*ansM%MOD << endl; 
    }
    else if(abs((N-M))<2 && N==M){
        cout << ansN*ansM*2%MOD << endl;
    }
    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) = explode(" ",trim(fgets(STDIN)));
//$v = explode(" ",trim(fgets(STDIN)));

$re = 1;
for($A=1;$A * $A <= $M;$A++) {
  if ($M % $A != 0) continue;
  $B = floor($M / $A);
  if ($A * $N <= $M) $re = max($re,$A);
  if ($B * $N <= $M) $re = max($re,$B);
}
printf("%d\n",$re);


Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            if(NextInt() == 1) {
                Console.WriteLine("Hello World");
            } else {
                Console.WriteLine(NextInt() + NextInt());
            }
        }
    }

    class MyMath {
        public static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#define _USE_MATH_DEFINES

typedef long long ll;
const ll MD = 1000000007;

#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;


/* sample input

*/

int main()
{

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

	for (int i = 0; i <= n - 1; i++) {
		ll rmin, rmax;
		rmin = i*c - d*(n - 1 - i);
		rmax = i*d - c*(n - 1 - i);
		
		if (rmin <= b - a&&b - a <= rmax) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
<?php
while (true) {
    list($H, $W) = array_map("intval", explode(' ', trim(fgets(STDIN))));
    if ($H == 0 && $W == 0) {
        break;
    }
    
    $line = str_repeat('#', $W) . "\n";
    $rectangle = str_repeat($line, $H);

    print($rectangle . "\n");
}
?>


Measured memory_bytes: 9332
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;
long long INF = 1000000009;
int main()
{
	int num;
	cin >> num;
	for (int i = 1; ; i++) {
		if (i * i > num) {
			cout << (i - 1) * (i - 1) << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
	int x = sc.nextInt();
    int y = sc.nextInt();
    
    boolean flag = true;
    double Kame = (y-2*x)/2;
    int kame = (int)Kame;
    if(Kame!=kame) flag = false;
    if(kame<0) {
      flag = false;
    }
    int turu = x-kame;
    if(turu<0) flag = false;
    if(turu+kame!=x || 2*turu+4*kame!=y) flag = false;
    
    if(flag == true){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

i64 dh[4] = {1, -1, 0, 0}, dw[4] = {0, 0, 1, -1};

int main()
{
  i64 h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (i64 i = 0; i < h; i++)
    cin >> a[i];
  queue<pair<pair<i64, i64>, i64>> que;
  for (i64 i = 0; i < h; i++)
    for (i64 j = 0; j < w; j++)
      if (a[i][j] == '#')
        que.push({{i, j}, 0});
  i64 ans = 0;
  while (que.size())
  {
    pair<pair<i64, i64>, i64> p = que.front();
    que.pop();
    ans = max(ans, p.second);
    for (i64 i = 0; i < 4; i++)
    {
      i64 hh = p.first.first + dh[i], ww = p.first.second + dw[i];
      if (0 <= hh && hh < h && 0 <= ww && ww < w && a[hh][ww] == '.')
      {
        a[hh][ww] = '#';
        que.push({{hh, ww}, p.second + 1});
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25524
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
using namespace std;

int main() {
	string s;
	cin >> s;
	long long sum = 0;
	int n = s.size();
	for (int temp = 0; temp < (1 << n - 1); temp++) {
		long long t = s[0] - '0';
		for (int i = 0; i < n - 1; i++) {
			if (temp & (1 << i)) {
				sum += t;
				t = s[i + 1] - '0';
			}
			else {
				t *= 10;
				t += s[i + 1] - '0';
			}
		}
		sum += t;
	}
	cout << sum;
	return 0;
}


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

int main() {
	int n, c = 0, mh = 0;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
		if (h.at(i) > mh)
			mh = h.at(i);
	}
	
	for (int i = 0; i < mh; i++)
		for (int j = 0; j < n; j++)
			if (h.at(j) > i && (j == 0 || h.at(j - 1) <= i))
				c++;
	cout << c << endl;
}


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


int main(void) {
  int n;
  cin >> n;
  int a;
  vector<int> memo;
  for (int i = 0; i < n; i++) {
    cin >> a;
    memo.push_back(a);
  }
  sort(memo.begin(), memo.end());
  int answer = 0;
  for (int i = 0; i < memo.size();) {
    int number = memo[i];
    int count = 0;
    for (; memo[i] == number && i < memo.size(); i++, count++);
    answer += count % 2;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vvi tree(n);
    rep(_,n-1) {
        int a,b;
        cin >> a >> b;
        tree[--a].pb(--b);
        tree[b].pb(a);
    }
    vi c(n);
    cin >> c;
    sort(rall(c));
    vi ans(n,inf);
    int ind = 0;
    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        int now = q.front();
        q.pop();
        ans[now] = c[ind++];
        for(int i : tree[now]) {
            if(ans[i] != inf) continue;
            q.push(i);
        }
    }
    int sum = 0;
    rep2(i,1,n) sum += c[i];
    cout << sum << endl << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)
#define ll long long
const ll mod=1e9+7;


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

  vector<int> a(n+1,1);
  r(i,m){
    int x;cin>>x;
    a.at(x)=0;
  }

  vector<ll> b(n+1);
  b.at(0)=1;
  r(i,n){
    for(int j=i+1;j<=min(n,i+2);j++){
      if(a.at(j)){
        b.at(j)+=b.at(i);
        b.at(j)%=mod;
      }
    }
  }

  cout<<b.at(n)<<endl;



  return 0;
}


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

int main(void){
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i=0 ; i<n ; ++i){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end(),greater<int>());
  int ans = 0;
  for(int i=0 ; i<k ; ++i){
    ans += vec.at(i);
  }

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

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b=sc.nextInt();
		int d=a/b, r=a%b;
		System.out.println(d +" "+r+" "+String.format("%.5f",(double)a/b));
	}

}



Measured memory_bytes: 26484
N=int(input())
res=[0]*(N+1)

for i in range(1,N+1):
    for j in range(1,N+1):
        if i*j>N:
            break
        res[i*j]+=1
ans=0
for i in range(N+1):
    ans+=res[i]*i
print(ans)

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

int main() {
  long double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  cout << fixed << setprecision(10) << sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) << endl;
}



Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    ll ans=0;
    ll a,b;
    cin >> a >> b;
    
    if(b<3){
        for(ll i=a; i<=b; i++){
            ans^=i;
        }
        cout<<ans<<endl;
        return 0;
    }
    
    while(a%4!=0){
        ans^=a;
        a++;
    }
    while(b%4!=3){
        ans^=b;
        b--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
P = sorted(list(map(int, input().split())))
dif = 0

for _ in range(300):
    if X - dif not in P:
        print(X - dif)
        exit()
    elif X + dif not in P:
        print(X + dif)
        exit()

    else:
        dif += 1

Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

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

int main() {
    int N; cin >> N;
    cout << (N * N * N) << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll powLL(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            res %= mod;
        }
        a = a*a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

const ll N_MAX = 300005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll Combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

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

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

    ll res = 0;
   	for(int k=1;k<M;k++){
    	ll tmp = 1;
    	tmp *= (M-k);
    	tmp %= mod;
    	tmp *= N;
    	tmp %= mod;
    	tmp *= N;
    	tmp %= mod;
    	res += (tmp * k % mod);
    	res %= mod;
    }
    for(int k=1;k<N;k++){
    	ll tmp = 1;
    	tmp *= (N-k);
    	tmp %= mod;
    	tmp *= M;
    	tmp %= mod;
    	tmp *= M;
    	tmp %= mod;
    	res += (tmp * k % mod);
    	res %= mod;
    }
    make();
    res *= Combination(N*M-2, K-2);
    res %= mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7296
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;
	in(n);
	int a[n];
	int tot = 0;
	for(int i=0;i<n;i++) {
		in(a[i]);
		tot = tot ^ a[i];
	}
	
	for(int i=0;i<n;i++) {
		cout<<(a[i] ^ tot)<<" ";
	}	
	cout<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 4468
#include <iostream>
#include <vector>

using namespace std;

int memo[100001];

int rec(int n){
  if(n == 0) return 0;
  if(memo[n] != -1) return memo[n];

  int res = n;
  for(int pow6=1;pow6<=n;pow6*=6) res = min(res, rec(n-pow6)+1);
  for(int pow9=1;pow9<=n;pow9*=9) res = min(res, rec(n-pow9)+1);
  return memo[n]=res;
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<100001;++i) memo[i]=-1;
  cout << rec(n) << endl;

  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int ans = 0;
  cin >> N;
  vector<int> cards(N);
  for(int n = 0; n < N; n++){
    cin >> cards.at(n);
  }
  sort(cards.begin(), cards.end(), greater<int>());
  for(int n = 0; n < N; n += 2){
    ans += cards.at(n);
  }
  for(int n = 1; n < N; n += 2){
    ans -= cards.at(n);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    // int i=1;
    // int count=1;
    // while(i*=2){
    //     count++;
    //     if(i>1e9){
    //         cout<<count<<endl;
    //         break;
    //     }
    // }

    int sum=0;
    rep(i,n) sum^=a[i];
    
    rep(i,n){
        //cout<<sum^10<<endl;
        int tmp=sum^a[i];
        cout<<tmp<<' ';
        //cout<<sum^a[i]<<' ';
    }
    // rep(i,n){
    //     int res=0;
    //     rep(j,n){
    //         if(i==j) continue;
    //         res^=a[j];
    //     }
    //     cout<<res<<' ';
    // }
    // cout<<endl;
    
}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;

ll a[N];
ll dp[N][(ll)1e5+11];
void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n>>k;
        
        
        for(i=1;i<=n;i++){
                cin>>a[i];
        }
        
        dp[0][0]=1;
        
        for(i=1;i<=n;i++){
                vll sum(k+1);
                sum[0]=dp[i-1][0];
                
                for(j=1;j<=k;j++){
                        sum[j]=sum[j-1]+dp[i-1][j];
                        sum[j]%=MOD;
                }
                for(j=0;j<=a[i];j++){
                        dp[i][j]=sum[j];
                }
                for(;j<=k;j++){
                        dp[i][j]=sum[j]-sum[j-a[i]-1];
                        dp[i][j]=(dp[i][j]+MOD)%MOD;
                }
                sum.clear();
        }
        cout<<dp[n][k]<<endl;
        
        
        
           
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 82436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  
  for(int i=0; i<N; i++) cin >> card.at(i);
 
  sort(card.begin(), card.end());
  reverse(card.begin(),card.end());
  
  int A=0;
  int B=0;
  for(int i=0; i<N; i+=2) A += card.at(i);
  for(int i=1; i<N; i+=2) B += card.at(i);
  
  cout << A - B << endl;
}

Measured memory_bytes: 3524
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val d = sc.nextDouble()
    val list = Array.fill(n)((sc.nextLong(), sc.nextLong()))

    var cnt = 0
    list.foreach { case (x, y) =>
      val z = Math.sqrt(x * x + y * y)
      if (d >= z) cnt += 1
    }

    println(cnt)

  }
}



Measured memory_bytes: 68260
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v: [i64; n],
        c: [i64; n],
    }

    let mut ans = 0;

    for b in 0..(1 << n) {
        let mut x = 0;
        let mut y = 0;
        for i in 0..n {
            if b & (1 << i) != 0 {
                x += v[i];
                y += c[i];
            }
        }

        ans = std::cmp::max(ans, x - y);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main()
{
    long long n, s;
    cin>>n>>s;
 
    for (long long b=2; b*b<=n; b++)
    {
        long long t = n;
        long long a = 0LL;
        while (t>0)
            a += t%b,
            t /= b;
        if (a==s)
        {
            cout<<b<<endl;
            return 0;
        }
    }
 
    long long inf = 1000000000000LL;
    long long ans = inf;
 
    if (n==s)
        ans = s+1;
 
    for (long long d=1; d*d<=n; d++)
    {
        long long r = s - d;
        long long b = (n-r)/d;
        if (0<=r && r<b && 2<=b && n/b+n%b==s && n/b<b)
            ans = min(ans, b);
    }
 
    cout<<(ans<inf ? ans : -1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1005,dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n,m,d[N][N],bx,by,ex,ey;
char s[N][N];
struct node
{
	int x,y,dis;
	node(){}
	node(int _x,int _y,int _dis):x(_x),y(_y),dis(_dis){}
	bool operator<(const node k)const
	{
		return dis>k.dis;
	}
};
priority_queue<node>pq;
int main()
{
	scanf("%d%d%d%d%d%d",&n,&m,&bx,&by,&ex,&ey);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
			d[i][j]=1e9;
	}
	d[bx][by]=0;
	pq.push(node(bx,by,0));
	while(!pq.empty())
	{
		node k=pq.top();
		pq.pop();
		int x=k.x,y=k.y,dis=k.dis;
		if(d[x][y]!=dis)
			continue;
		for(int i=0;i<4;i++)
		{
			int kx=x+dx[i],ky=y+dy[i];
			if(kx<1||kx>n||ky<1||ky>m||s[kx][ky]=='#')
				continue;
			if(d[kx][ky]>dis)
			{
				d[kx][ky]=dis;
				pq.push(node(kx,ky,dis));
			}
		}
		for(int i=-2;i<=2;i++)
		{
			for(int j=-2;j<=2;j++)
			{
				int kx=x+i,ky=y+j;
				if(kx<1||kx>n||ky<1||ky>m||s[kx][ky]=='#')
					continue;
				if(d[kx][ky]>dis+1)
				{
					d[kx][ky]=dis+1;
					pq.push(node(kx,ky,dis+1));
				}
			}
		}
	}
	if(d[ex][ey]==1e9)
		d[ex][ey]=-1;
	printf("%d\n",d[ex][ey]);
	return 0;
}

Measured memory_bytes: 8796
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0] * (N + 1)
    MAX = 9999999
    for a in A:
        B[a] += 1
    B.sort(reverse=True)
    s = 0
    for i in range(0, K):
        s += B[i]
    return sum(B) - s


print(main())


Measured memory_bytes: 25004