akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K,M;
int A[252525];
int cnt[404];
ll mo=1000000007;

ll dp[25205][2][404], dp2[2][404];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>M;
	FOR(i,M) cin>>A[i], A[i]--;
	
	ll tot=(N-M+1);
	FOR(i,N-M) (tot*=K)%=mo;
	
	for(i=0;i+K<=M;i++) {
		ZERO(cnt);
		int ok=0;
		for(j=i;j<i+K;j++) if(++cnt[A[j]]==2) ok++;
		if(ok==0) {
			cout<<tot<<endl;
			return;
		}
	}
	
	
	dp[1][0][1]=K;
	dp[1][M==1][1]=K;
	for(i=2;i<=N;i++) {
		ZERO(dp2);
		for(j=1;j<K;j++) {
			(dp[i][0][j+1]+=(K-j)*dp[i-1][0][j])%=mo;
			(dp[i][1][j+1]+=(K-j)*dp[i-1][1][j])%=mo;
			dp2[0][1]+=dp[i-1][0][j];
			dp2[0][j+1]+=mo-dp[i-1][0][j];
			dp2[1][1]+=dp[i-1][1][j];
			dp2[1][j+1]+=mo-dp[i-1][1][j];
		}
		
		for(j=1;j<K;j++) {
			dp2[0][j]+=dp2[0][j-1];
			(dp[i][0][j]+=dp2[0][j])%=mo;
			dp2[1][j]+=dp2[1][j-1];
			(dp[i][1][j]+=dp2[1][j])%=mo;
			if(j>=M) (dp[i][1][j]+=dp[i][0][j])%=mo;
		}
	}
	ZERO(cnt);
	FOR(i,M) cnt[A[i]]++;
	FOR(i,K) if(cnt[i]>1) break;
	
	ll ret=0;
	if(i<K) {
		int F,B;
		set<int> S;
		FOR(F,M) {
			if(S.count(A[F])) break;
			S.insert(A[F]);
		}
		S.clear();
		FOR(B,M) {
			if(S.count(A[M-1-B])) break;
			S.insert(A[M-1-B]);
		}
		for(int L=0;L<=N-M;L++) {
			int R=N-M-L;
			ll LP=0,RP=0;
			for(j=F;j<K;j++) LP+=dp[L+F][0][j];
			for(j=B;j<K;j++) RP+=dp[R+B][0][j];
			LP%=mo;
			RP%=mo;
			ll LM=1,RM=1;
			for(i=K-F+1;i<=K;i++) LM=LM*i%mo;
			for(i=K-B+1;i<=K;i++) RM=RM*i%mo;
			(ret += (LP*modpow(LM))%mo*(RP*modpow(RM)%mo))%=mo;
		}
		
	}
	else {
		// no same
		for(j=1;j<K;j++) ret+=dp[N][1][j];
		ret%=mo;
		ll di=1;
		for(i=K-M+1;i<=K;i++) di=di*i%mo;
		ret=ret*modpow(di)%mo;
		
		
		
	}
		cout<<(tot-ret+mo)%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 160000
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, a;
    int buck[100010] = {};
    int max = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;

        buck[a]++;
        buck[a+1]++;
        buck[a-1]++;
    }

    for (int i = 0; i <= 100000; i++) {
        if (max < buck[i]) {
            max = buck[i];
        }
    }

    cout << max << endl;
}



Measured memory_bytes: 640
N, M = map(int, input().split())
AB = []

for _ in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB = sorted(AB)


sum = 0
ans = 0
for i in range(N):
    sum += AB[i][1]
    ans += AB[i][1] * AB[i][0]
    if sum >= M:
        ans -= (sum - M) * AB[i][0]
        break

print(ans)

Measured memory_bytes: 59480
#include<stdio.h>
#include<string.h>
 
#define MAX 2000001
#define MAX_SCORE 10001
 
typedef struct {
  int id;
  int score;
  int rank;
} Info;
 
int n; // number of students
int counter[MAX_SCORE+1], maxi;
Info list[MAX+1], sortedList[MAX+1];
 
 
void CountingSort() {
  memset(counter,0,sizeof counter);
  int i;
  for(i=0;i<n;++i) ++counter[list[i].score];
  for(i=1;i<=maxi;++i) counter[i] += counter[i-1];
  for(i=n-1;i>=0;--i) {
    sortedList[--counter[list[i].score]] = list[i];
  }
}
 
int main() {
  int i, id, score;
  while( scanf("%d",&n) != EOF ) {
    maxi = 0;
    for(i=0;i<n;++i) {
      scanf("%d",&score);
      list[i].score = score;
      if( maxi < score ) maxi = score;
    }
    CountingSort();
    for(i=0;i<n;++i) {
      if( i ) printf(" ");
      printf("%d",sortedList[i].score);
    } puts("");
  }
  return 0;
}


Measured memory_bytes: 48656
def main():
    import sys
    input = sys.stdin.buffer.readline
    from itertools import permutations
    N, M = (int(i) for i in input().split())
    edge = [[] for _ in range(N)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)

    ans = 0
    for p in permutations(range(1, N)):
        v = 0
        for nv in p:
            if nv in edge[v]:
                v = nv
            else:
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67460
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000000;

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    int N;
    cin >> N;
    int next = 1;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a == next) {
            cnt++;
            next++;
        }
    }
    if (cnt == 0) {
        cout << -1 << endl;
    } else {
        cout << N - cnt << endl;
    }
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll M;
  scanf("%lld",&M);
  ll X;
  scanf("%lld",&X);
  vector<ll> A(N+1,0);
  for(int i = 0 ; i < M ; i++){
    ll t;
    scanf("%lld",&t);
    A[t]=1;
  }
  ll cl=0;
  ll cr=0;
  for (int i=1; i<N; i++) {
    if (i<X) cl+=A[i];
    if (i>X) cr+=A[i];
  }
  cout << min(cl,cr) << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define fix cout<<fixed<<setprecision(20);
const int maxn=(int)1e6+5;
long long a[maxn],ans;
unordered_map<int,long long> mp;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;rep(i,1,n)cin>>a[i];
    for(int i=n;i>=1;i--){
        if(mp.count(a[i]+i))ans+=mp[a[i]+i];
        mp[i-a[i]]++;
    }
    cout<<ans<<endl;
}
/* 
multi_set T
i>j:
Ai+Aj=i-j
Ai-i=-j-Aj
i<j:
Ai+Aj=j-i
Ai+i=j-Aj
 */

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

struct bit2d_t
{
	static const int max_x = 4005;
	static const int max_y = 4005;
	static const int neutral_val = 0;
	
	int tree[max_x][max_y];
	
	void update (int x, int y, int val)
	{
		assert(x > 0 && y > 0);
		
		for (int i = x; i < max_x; i += i & -i)
		{
			for (int j = y; j < max_y; j += j & -j)
			{
				tree[i][j] += val;
			}
		}
	}
	
	int query (int x1, int y1, int x2, int y2)
	{
		assert(x1 > 0 && y1 > 0 && x2 > 0 && y2 > 0);
		
		return sum(x2,y2) - sum(x1-1,y2) - sum(x2,y1-1) + sum(x1-1,y1-1);
	}
	
private:

	int sum (int x, int y)
	{	
		int ans = neutral_val;
		for (int i = x; i > 0; i &= i - 1)
		{
			for (int j = y; j > 0; j &= j -1)
			{
				ans += tree[i][j];
			}
		}
		
		return ans;
	}
};

bit2d_t bitw;
bit2d_t bitb;

int main (int argc, char const* argv[])
{
	int n,k;
	scanf("%d %d",&n,&k);
	
	for (int i = 0; i < n; i += 1)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		
		char col[5];
		scanf("%s",col);
		
		x %= 2*k;
		y %= 2*k;
		
		if (col[0] == 'B')
		{
			bitb.update(x+1,y+1,1);
			bitb.update(x+1,y+1+2*k,1);
			bitb.update(x+2*k+1,y+1+2*k,1);
			bitb.update(x+2*k+1,y+1,1);
		}
		else
		{
			bitw.update(x+1,y+1,1);
			bitw.update(x+1,y+1+2*k,1);
			bitw.update(x+2*k+1,y+1+2*k,1);
			bitw.update(x+2*k+1,y+1,1);
		}
	}

	int ans = 0;
	for (int i = 0; i < k; ++i)
	{
		for (int j = 0; j < k; j += 1)
		{
			///WHITE
			{
				int sum = bitw.query(i+1,j+1,i+1+(k-1),j+1+(k-1)) +
					bitw.query(i+1+k, j+k+1, i+1+k+(k-1), j+k+1+(k-1)) +
					bitb.query(i+k+1, j+1, i+k+1+(k-1),j+1+(k-1)) +
					bitb.query(i+1, j+k+1, i+1+(k-1), j+k+1+(k-1));
					
				ans = max(ans,sum);
			}
			
			{
				int sum = bitb.query(i+1,j+1,i+k,j+k) +
					bitb.query(i+1+k, j+k+1, i+1+k+(k-1), j+k+1+(k-1)) +
					bitw.query(i+k+1, j+1, i+k+1+(k-1),j+1+(k-1)) +
					bitw.query(i+1, j+k+1, i+1+(k-1), j+k+1+(k-1));
					
				ans = max(ans,sum);
			}
		}
	}
	
	printf("%d\n",ans);
		
	return 0;
}

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    int b[m], a[n][m];
    rep(i,m){
        cin >> b[i];
    }
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int count=0;
    rep(i,n){
        int big=0;
        rep(j,m){
            big+=a[i][j]*b[j];
        }
        big+=c;
        if(big>0){
            count++;
        }
    }
    cc(count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res){
	char c;T flag=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
	while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)cout<<c<<endl;
    if(b==c)cout<<a<<endl;
    if(a==c)cout<<b<<endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

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


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int a, b, c, d, f;
    cin >> a >> b >> c >> d >> f;

    if (a == 0){
        cout << 1 << "\n";
    }else if (b == 0){
        cout << 2 << "\n";
    }else if (c == 0){
        cout << 3 << "\n";
    }else if (d == 0){
        cout << 4 << "\n";
    }else if (f == 0){
        cout << 5 << "\n";
    }
    
    

    return 0;
}


Measured memory_bytes: 3636
import sys
import itertools
import bisect

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    comb = itertools.product([0, 1], repeat=16)

    p = []
    m = []
    for c in comb:
        pt, mt = 0, 0
        for i in range(len(c)):
            pt += c[i] * (4 ** i)
            mt += c[i] * 2 * (4 ** i)
        p.append(pt)
        m.append(mt)

    p.sort()
    m.sort()

    for i in range(len(p)):
        if p[i] < N:
            continue
        else:
            pred_m = -(N - p[i])
            j = bisect.bisect_left(m, pred_m)
            if m[j] == pred_m:
                pred_p = p[i]
                break

    ans = pred_p | pred_m
    print(bin(ans)[2:])


if __name__ == '__main__':
    main()


Measured memory_bytes: 73264
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c2 = 0;
        int c4 = 0;
        int c = 0;
        for (int i = 0; i < n; i++) {
            Long l = sc.nextLong();
            if (l % 4 == 0) {
                c4++;
            } else if (l % 2 == 0) {
                c2++;
            } else {
                c++;
            }
        }
        if (c2 == 0) {
            if (c <= c4 + 1) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            if (c <= c4) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


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

Measured memory_bytes: 512
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while( scan.hasNextInt() ) {
			Integer[] ary = new Integer[6];
			
			for(int i = 0; i < 6; i++) {
				ary[i] = scan.nextInt();
			}
			
			double x = (double)1 / (double)((ary[0]*ary[4])-(ary[1]*ary[3])) * (double)((ary[4]*ary[2])-(ary[1]*ary[5]));
			double y = (double)1 / (double)((ary[0]*ary[4])-(ary[1]*ary[3])) * (double)((-(ary[2]*ary[3])+(ary[0]*ary[5])));
			
			if(Math.abs(x) < 0.005) {
				x = 0;
			}
			if(Math.abs(y) < 0.005) {
				y = 0;
			}
			
			System.out.printf("%.3f %.3f\n", x, y);
			
		}
	}
}

Measured memory_bytes: 18256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Equal Sum Sets
 */
public class Main {

	public static int count;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int n, k, s;
			n = parseInt(st.nextToken());
			k = parseInt(st.nextToken());
			s = parseInt(st.nextToken());
			if ((n | k | s) == 0) break;

			count = 0;
			solve(n, k, s);

			System.out.println(count);

		} //end while
	} //end main

	public static void solve(int n, int c, int r) {

		if (c == 0) {
			if (r == 0) count++;
			return;
		}

		if (n == 0) {
			return;
		}

		solve(n - 1, c - 1, r - n);
		solve(n - 1, c, r);
	}
}

Measured memory_bytes: 24300
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < d.length; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		int f = d.length / 2 - 1;
		int s = f + 1;
		System.out.println(d[s] - d[f]);
		sc.close();
	}
}


Measured memory_bytes: 50160
import sys
#input = sys.stdin.buffer.readline

def main():
    N,A,B,C = map(int,input().split())
    use = [A,B,C]
    conv = ["A","B","C"]
    
    l = []
    for _ in range(N):
        s = input()
        if s == "AB":
            s = 0
        elif s == "BC":
            s = 1
        else:
            s = 2
        l.append(s)
        
    ans = []
        
    for i in range(N):
        num = l[i]
        if use[num]+use[(num+1)%3] == 0:
            print("No")
            exit()
        elif use[num] == use[(num+1)%3] == 1:
            if i == N-1:
                ans.append(conv[num])
                use[num] += 1
                use[(num+1)%3] -= 1
            else:
                _num = l[i+1]
                if num == _num:
                    ans.append(conv[num])
                    use[num] += 1
                    use[(num+1)%3] -= 1
                else:
                    if (_num+3-num)%3 == 1:
                        ans.append(conv[_num])
                        use[_num] += 1
                        use[(_num-1)%3] -= 1
                    else:
                        ans.append(conv[num])
                        use[num] += 1
                        use[(num+1)%3] -= 1
        else:
            if use[num] >= use[(num+1)%3]:
                ans.append(conv[(num+1)%3])
                use[num] -= 1
                use[(num+1)%3] += 1
            else:
                ans.append(conv[num])
                use[num] += 1
                use[(num+1)%3] -= 1

    print("Yes")
    for st in ans:
        print(st)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 82520
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>
#include <tuple>
#include <cmath>
#include <chrono>
#include <map>

using namespace std;

using ll = long long;

int main() {
    string s, t;
    cin >> s >> t;
    
    int n = s.size();
    
    map<char, char> m1, m2;
    
    for (int i = 0; i < n; i++) {
        if (m1.count(s[i])){
            if (m1[s[i]] != t[i]) {
                cout << "No" << endl;
                return 0;
            }
        } else if(m2.count(t[i])) {
            if (m2[t[i]] != s[i]) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            m1[s[i]] = t[i];
            m2[t[i]] = s[i];
        }
    }
    
    cout << "Yes" << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint h,w,K;std::cin>>h>>w>>K;
    std::vector<std::vector<lint>>a(h+1,std::vector<lint>(w+1));
    for(lint i=1;i<=h;i++){
        for(lint j=1;j<=w;j++){
            char c;std::cin>>c;
            a.at(i).at(j)=c-'0'+a.at(i-1).at(j)+a.at(i).at(j-1)-a.at(i-1).at(j-1);
        }
    }
    lint H=1ll<<h,ans=h*w;
    for(lint bs=H/2;bs<H;bs++){
        lint now=__builtin_popcountll(bs)-2;
        for(lint i=0,j=0;j<=w;j++){
            for(lint k=0,l=1;l<=h;l++){
                if(!(bs>>l-1&1))continue;
                if(j==w||K<a.at(l).at(j+1)-a.at(l).at(i)-a.at(k).at(j+1)+a.at(k).at(i)){
                    now++;
                    if(i==j)goto Impossible;
                    else {i=j;break;};
                }
                k=l;
            }
        }
        if(now<ans)ans=now;
        Impossible:;
    }
    std::cout<<ans<<'\n';
}



Measured memory_bytes: 384
mod = 1000000007
def gcd(a, b):
    while(b > 0):
        a = a%b
        c = b
        b = a
        a = c
    return a

n = int(input())
s = input()

s = s.split(" ")

l = int(s[0])

for i in range(1, n):
    l = (l*int(s[i]))//gcd(l, int(s[i]))

ans = 0
for x in s:
    x = int(x)
    ans = (ans +l//x)

print(ans%mod)




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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

int n, s = 0;
vector<int> a;

ModInt<> solve();

int main() {
  cin >> n;
  a.resize(n);
  for (auto &p : a) {
    cin >> p;
    s ^= p;
  }
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res;
  // zero(zero)
  if (!s) {
    int now = 0, zero = 0;
    for (int i = 0; i < n; ++i) {
      now ^= a[i];
      if (!now) ++zero;
    }
    res += ModInt<>(2).pow(zero - 1);
  }
  // zero(nonzero)
  {
    int now = 0, zero = 0;
    vector<int> cnt(1 << 20, 0);
    vector<vector<ModInt<>>> dp(2, vector<ModInt<>>(1 << 20, 1));
    dp[1].assign(1 << 20, 0);
    for (int i = 0; i < n; ++i) {
      now ^= a[i];
      if (now) {
        dp[0][now] += dp[1][now] * (zero - cnt[now]);
        dp[1][now] += dp[0][now];
        cnt[now] = zero;
      } else
        ++zero;
    }
    if (!s)
      for (auto p : dp[1]) res += p;
    else
      res = dp[0][s];
  }
  return res;
}


Measured memory_bytes: 21716
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let d:u32 = read();

    let d = 25-d;
    let mut s = String::from("Christmas");
    for i in 0..d {
        s.push_str(" Eve");
    }

    println!("{}", s);

}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
// utility
#include <bitset>
#include <tuple>
#include <typeinfo>
// error handling
#include <cassert>
// string
#include <cctype>
#include <cstring>
#include <string>
// container
#include <array>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// algorithm
#include <algorithm>
// iterator
#include <iterator>
// math
#include <cmath>
#include <complex>
#include <numeric>
#include <random>
// i/o
#include <cstdio>
#include <iomanip>
#include <iostream>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> L(M), R(M);
  rep(i, 0, M) { cin >> L[i] >> R[i]; }
  vector<int> p(Q), q(Q);
  rep(i, 0, Q) { cin >> p[i] >> q[i]; }

  vector<vector<int>> sum(N + 1, vector<int>(N + 1));
  rep(i, 0, M) { sum[L[i]][R[i]]++; }

  printvv(sum);
  rep(i, 1, N + 1) rep(j, 1, N + 1) {
    sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
  }

  rep(i, 0, Q) {
    dump(q[i],q[i]);
    dump(p[i]-1,p[i]-1);
    dump(p[i]-1,q[i]);
    dump(q[i],p[i]-1);
    int ans = sum[q[i]][q[i]] + sum[p[i] - 1][p[i] - 1] - sum[p[i] - 1][q[i]] -
              sum[q[i]][p[i] - 1];
    cout << ans << endl;
  }
  printvv(sum);

  return 0;
}


Measured memory_bytes: 7680
import math

n=int(input())
s=0
l=[]

x=input()
x=x.split(' ')


for i in range(n):
  s=s+int(x[i])
  l.append(s)


m = abs(l[0]-(s-l[0]))

for i in range(1,n-1):
  if m > abs(l[i]-(s-l[i])):
    m=abs(l[i]-(s-l[i]))
    
print(m)

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;
using namespace std;
long long h[10000010],x[10000010];

signed main(){
      
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string a,b,c;
  cin>>a>>b>>c;

  if(a[a.size()-1]==b[0]){
      if(b[b.size()-1]==c[0]) cout<<"YES"<<'\n';
      else cout<<"NO"<<'\n';
  }else cout<<"NO"<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

//static const double PI = 3.141592653589793238462643383279;
static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

ll n, a, b;
ll h[100001];
ll t[100001];

bool condition(ll x) {
	rep(i, 0, n) {
		t[i] = h[i];
	}
	rep(i, 0, n) t[i] -= x * b;
	ll cnt = 0;
	rep(i, 0, n) {
		if (t[i] > 0) {
			ll d = a - b;
			cnt += t[i] / d;
			if (t[i] % d != 0)cnt++;
		}
	}
	return cnt <= x;
}

int main() {
	cin >> n >> a >> b;
	rep(i, 0, n) {
		cin >> h[i];
	}

	ll r = (ll)1 << 30;
	ll l = -1;
	ll m;

	while (l + 1 != r) {
		m = (l + r) / 2;
		//cout << m << endl;
		if (condition(m)) {
			r = m;
		}
		else {
			l = m;
		}
	}

	cout << r << endl;

	return 0;
}

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

int main(){
	int n,number;
	long long a,b;
	bool flag;
	map<int,long long> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number); // 既出だったら表示順記録配列に入れない。単価0円ケースを考慮してません。
			info[number] += a*b;
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	int cur=0;
	for(int i=0;i<s.size();i++)cur=(cur*10+s[i]-'0')%9;
	if(cur==0)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int n;cin>>n;
	int a[n];
	map<int,int>mp;
	for(int i = 0; i < n; ++i){cin>>a[i];mp[a[i]]++;}
	
	int ans = 0;

	for(int i=-1;i<1e5;i++){

		int cnt = mp[i] + mp[i+1] + mp[i-1];

		ans = max(ans,cnt);

	}

	cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 8664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int N=sc.nextInt(), K=sc.nextInt(), Q=sc.nextInt();
        int[] arr = new int[N+1];
        for (int i=0; i<Q; i++) {
            int temp = sc.nextInt();
            arr[temp]++;
        }
        for (int i=1; i<=N; i++) {
            if (K-Q+arr[i]>0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 42628
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();
      if(Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(c - b) <= d)
        System.out.println("Yes");
      else
        System.out.println("No");
  }
}


Measured memory_bytes: 21204
//Attention.cpp (C)
#include <iostream>
using namespace std;

int main(){
  int N,Ans,Amin;
  Ans = 0;
  Amin = 3*110000;
  cin >> N;
  int W[N];
  int E[N];
  char S[N];
  cin >> S;
  if(S[0]=='W') W[0] = 1;
  else E[0] = 1;
  for(int i = 1; i < N; i++){
    W[i] = W[i-1];
    if(S[i]=='W') ++W[i];
    E[i] = E[i-1];
    if(S[i]=='E') ++E[i];
  }

  for(int i = 0; i < N; i++){
    if(i==0) Ans = E[N-1] - E[0];
    else if(i==N-1) Ans = W[N-2];
    else Ans = W[i-1] + E[N-1] - E[i];
    Amin = min(Ans,Amin);

  }

  printf("%d\n",Amin);

}


Measured memory_bytes: 2944
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val r = sc.nextInt()
    val s = sc.nextInt()
    val p = sc.nextInt()
    val t = sc.next()
    println(problem149d(n, k, r, s, p, t))
}

fun problem149d(n: Int, k: Int, r: Int, s: Int, p: Int, t: String): Long {
    val getPoint = fun(c: Char): Pair<Long, Char> = when(c) {
        'r' -> p.toLong() to 'p'
        's' -> r.toLong() to 'r'
        'p' -> s.toLong() to 's'
        else -> 0L to '_'
    }
    val dp = Array(n) { 0L to '_' }
    dp[0] = getPoint(t[0])
    for (i in 1 until n) {
        val win = getPoint(t[i])
        if (i >= k && win.second == dp[i - k].second) {
            dp[i] = dp[i - 1].first to '_'
        } else {
            dp[i] = dp[i - 1].first + win.first to win.second
        }
    }
    return dp[n - 1].first
}


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  int ans = 0;
  vector<int> B(N);
  for( int i=0;i<N-1;i++)
    cin >> B[i];

  B[N-1] = 1000000;

  for( int i=N-1;i>0;i--)
    {
      ans += min(B[i],B[i-1]);
    }
  ans += B[0];
  cout << ans << endl;
}


Measured memory_bytes: 256
// Author : Mohamed Sameh
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<stack>
#include<deque>
#include <cstring>
#include <iomanip>    
using namespace std ;
typedef long long ll ;

#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define PI  3.141592 
#define SZ(a) (int)a.size()
void READ (string INPUT = "NO" , string OUTPUT = "NO" )
{
    if (INPUT != "NO")
    freopen(INPUT.c_str() , "r" , stdin );
    if (OUTPUT!="NO")
    freopen ( OUTPUT.c_str() , "w" , stdout);
} 
int n  ; 
int dp[100001][4]; 
int h[100001][3]; 
int solve (int i,int last )
{
    if (i == n )
        return 0 ;
    if (dp[i][last]!=-1)return dp[i][last] ;
    int &ret = dp[i][last] ; 
    ret = 2e9 ; 
    if (last == 3 )
    {
        ret = max (  max ( h[i][0] + solve(i+1,0) ,h[i][1] + solve(i+1,1) ),h[i][2] + solve(i+1,2)) ; 
    }else if (last == 0 )
    {
        ret = max (h[i][1] + solve(i+1,1) ,h[i][2] + solve(i+1,2)) ;
    }else if (last == 1 )
    {
        ret = max (h[i][0] + solve(i+1,0) ,h[i][2] + solve(i+1,2)) ;
    }else 
    {
        ret = max (h[i][0] + solve(i+1,0) ,h[i][1] + solve(i+1,1)) ;
    }
    return ret ; 
}
int main ()
{
    memset (dp,-1,sizeof dp );
    scanf ("%d" , &n ); 
    for (int i =0 ; i < n ;i++)
        scanf ("%d%d%d" , &h[i][0] , &h[i][1] , &h[i][2]); 
    printf ("%d\n" , solve(0,3)); 
    return 0 ; 
}

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

using namespace std;
long long arr[200007];
long long nums[200007];

int main() { 
    long long n,maxi=0,x,sum;
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>nums[i];
        arr[nums[i]]++;
        maxi=max(nums[i],maxi);
    }
    for (int i=1;i<=maxi;i++) sum+=arr[i]*(arr[i]-1)/2;
    for (int k=1;k<=n;k++) cout<<sum-(arr[nums[k-1]]-1)<<"\n";
    return 0; 
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;       //     ____   _   _  __   __
#define ll long long       //    / ___| | |_| |   / /
const ll INF = 0x3f3f3f3f; //   | |     |  _  |   V /
const ll N   = 1e5 + 5;    //   | |___  | | | |   | |
const ll MOD = 1e9 + 7;    //    ____| |_| |_|   |_|
ll read() {
  ll   x = 0, f = 1;
  char ch = getchar();

  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1; ch = getchar();
  }

  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0'; ch = getchar();
  }
  return x * f;
}

int main() {
  ll n = read();

  cout << n * n << endl;
  return 0;
}


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

typedef struct {
	int h,m;
} zikoku_t;

int qsc(const void *x,const void *y) {
	zikoku_t *a=(zikoku_t*)x;
	zikoku_t *b=(zikoku_t*)y;
	int aa=a->h*60+a->m;
	int bb=b->h*60+b->m;
	if(aa>bb)return 1;
	if(aa<bb)return -1;
	return 0;
}

int main(void) {
	int N,M;
	int i;
	zikoku_t zikokuhyo[200];
	if(scanf("%d",&N)!=1)return 1;
	for(i=0;i<N;i++) {
		if(scanf("%d%d",&zikokuhyo[i].h,&zikokuhyo[i].m)!=2)return 1;
	}
	if(scanf("%d",&M)!=1)return 1;
	for(i=0;i<M;i++) {
		if(scanf("%d%d",&zikokuhyo[N+i].h,&zikokuhyo[N+i].m)!=2)return 1;
	}
	qsort(zikokuhyo,N+M,sizeof(zikokuhyo[0]),qsc);
	for(i=0;i<N+M;i++) {
		if(i==0) {
			printf("%d:%02d",zikokuhyo[i].h,zikokuhyo[i].m);
		} else if (zikokuhyo[i].h!=zikokuhyo[i-1].h || zikokuhyo[i].m!=zikokuhyo[i-1].m) {
			printf(" %d:%02d",zikokuhyo[i].h,zikokuhyo[i].m);
		}
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 660
#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);
  }
  
  int count = 1;
  bool x = true;
  
  for(int i = 1; i < N; i++) {
    for(int j = 0; j < i; j++) {
      if(vec.at(i) < vec.at(j)) {
        x = false;
        break;
      }
    }
    if(x) {
      count++;
    }
    x = true;
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n, a, b; cin >> n>> a>> b;
        int per= a+ b;
        int wh= n/ per;
        int md= n% per;
        cout << (wh* a+ min(md, a))<< "\n";
        return;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const int maxn = 5e5 + 50;
typedef pair<int, int> P;

int arr[maxn];
int a, b, c, d, e, f, g;
void solve();
int main()
{
	int t = 1;
//	cin >> t;
	for(int i=0; i<t; i++)
	{
		solve();
	}
	return 0;
}

// type below

void solve()
{
	set<string> S;
	cin >> a;
	for(int i=0; i<a; i++)
	{
		string str; cin >> str;
		S.insert(str);
	}
	cout << S.size() << '\n';
}

Measured memory_bytes: 19044
IINF = 10 ** 18


def main():
    N, M = list(map(int, input().split()))
    X = list(map(int, input().split()))
    X = sorted(X)
    # left = -IINF
    # right = IINF

    # print(M, N)
    if M <= N:
        print(0)
        return
    else:
        L = []
        for i in range(M-1):
            L.append(X[i+1]-X[i])

        # print(L)

        L.sort()
        if N == 1:
            ans = sum(L)
            print(ans)
        else:
            ans = sum(L[0:-(N-1)])
            print(ans)

    # for i in range(N):
    #     if len(X) == 0:
    #         break
    #     elif i == 0:
    #         left = X[0]
    #         X.pop(0)
    #     elif i == 1:
    #         right = X[-1]
    #         X.pop(len(X)-1)
    #     else:
    #         if abs(X[1] - X[-1]) < abs(X[-2] - X[0]):
    #             left = X[0]
    #             X.pop(0)
    #         else:
    #             right = X[-1]
    #             X.pop(-1)

    # ans = 0
    # while len(X) > 0:
    #     # print(ans, X)
    #     if abs(left - X[0]) < abs(right - X[-1]):
    #         ans += abs(left - X[0])
    #         left = X[0]
    #         X.pop(0)
    #     else:
    #         ans += abs(right - X[-1])
    #         right = X[-1]
    #         X.pop(len(X)-1)
    #     # b = min(abs(left - X[0]), abs(right - X[-1]))
    #     # print(b, X)
    #     # print(abs(X[0] - X[-1]) + b)
    # print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57384
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=300+10;

    int dp[N][N][N];
    void main()
	{
        int n=qread(),m=qread();dp[0][1][0]=1;
        fo(i,0,m-1) fo(done,0,n) fo(siz,0,n-done)
        {
            ll now=dp[i][done][siz];if(!now) continue;
            add(dp[i+1][done+siz][0],now*done%MOD);
            add(dp[i+1][done][siz],now*siz%MOD);
            add(dp[i+1][done][siz+1],now*(n-done-siz)%MOD);
        }write(dp[m][n][0]);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 112896
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	int X, N, p;
	bool flag[102] = { false };
	cin >> X >> N;
	REP(i, N) {
		cin >> p;
		flag[p] = true;
	}

	int ans = 0;
	int diff, min_diff = 102;
	REP(i, 102) {
		if (flag[i]) continue;
		diff = abs(X - i);
		if (diff < min_diff) {
			min_diff = diff;
			ans = i;
		}
	}

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

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int arr[2000005], dist[2000005], K, N;
int main(){
  cin >> K >> N;
  for (int i = 1; i<=N; ++i){
    cin >> arr[i];
  }
  for (int i = 1; i<N; ++i){
    dist[i] = arr[i+1] - arr[i];
  }
  int total = (K - arr[N]) + arr[1];
  for (int i = 1; i<N; ++i){
    total = max(total, dist[i]);
  }
  cout << K - total << endl;
  return 0;
}

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

#define ll long long

int main()
{
	ll a;
	double b;
	cin >> a >> b;
	ll ib = b * 100 + 0.5;
	a *= ib;
	a /= 100;
	printf("%lld\n", a);
	return 0;
}

Measured memory_bytes: 3732
import sys
from collections import defaultdict

n, a, *x = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        x[i] -= a
    
    c = defaultdict(int)
    c[0] = 1
    for i in x:
        for val, cnt in tuple(c.items()):
            c[val+i] += cnt
    ans = c[0] - 1
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3572
class Msort
  attr_reader :arr, :count, :tcount

  def initialize(arr)
    @arr = arr
    @count = 0
    @tcount = 0
  end

  def exec(array=arr)
    if array.length == 1
      array
    else
      mid = array.length / 2 - 1
      merge(exec(array[0..mid]), exec(array[mid+1..-1]))
    end
  end

  def merge(left, right)
    tl = left.shift
    tr = right.shift
    result = []
    loop do
      break if [tl, tr].all?(&:nil?)
      @count += 1
      if tl.nil?
        result << tr
        tr = right.shift
        next
      end
      if tr.nil?
        result << tl
        tl = left.shift
        next
      end
      if tl <= tr
        result << tl
        tl = left.shift
      else
        @tcount += left.length + 1
        result << tr
        tr = right.shift
      end
    end
    result
  end
end

n = gets.to_i
arr = gets.split.map(&:to_i)
m = Msort.new(arr)
m.exec
puts m.tcount


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

// {{{ Template for Competitive Programming
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0 ,1 ,0,-1};
using vint = vector<int>;
using pint = pair<int, int>;
// }}}

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



Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  ll N, A, B;
  cin >> N >> A >> B;

  bool ok = true;  
  if (A > B) ok = false;
  if (N == 1 && A != B) ok = false;

  if (!ok) {
    cout << 0 << endl;
    return 0;
  }

  ll minNum = (N - 1) * A + B;
  ll maxNum = A + (N - 1) * B;

  cout << maxNum - minNum + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const double PI = acos(-1);
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double r;
  cin >> r;
  printf("%.7f\n", r*2.0*PI);
  return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  ll ans = 0, m = 1e9;
  int cnt = 0; bool is0 = false;
  rep(i,n) {
    ll a;
    cin >> a;
    ans += abs(a);
    m = min(m,abs(a));
    if(a==0) is0 = true;
    if(a<0) ++cnt;
  }
  if(!is0 && cnt%2==1){
    ans -= 2LL*m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	if ((s[2] == s[3]) && (s[4] == s[5])) cout << "Yes\n";
	else cout << "No\n";
		

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;                                                   

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String w = in.next();
        int a = 0;
        while(in.hasNext()){
            String str = in.next();
            if(str.equals("END_OF_TEXT")){
                break;
            }else if(str.equalsIgnoreCase(w)){
            a++;
            }
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 25924
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

int main(void)
{
    int64_t n;
    std::cin >> n;

    struct List {
        int64_t t = 0;
        int64_t x = 0;
        int64_t y = 0;
    };

    std::vector<List> list;

    List first;
    list.emplace_back(std::move(first));

    for (int64_t i=0; i < n; ++i) {
        List e;
        std::cin >> e.t >> e.x >> e.y;
        list.emplace_back(std::move(e));
    }

    auto judge = [&](){
        for (uint64_t i=1; i < list.size(); ++i) {
            int64_t dt = std::abs(list.at(i).t - list.at(i-1).t);
            int64_t dx = std::abs(list.at(i).x - list.at(i-1).x);
            int64_t dy = std::abs(list.at(i).y - list.at(i-1).y);
            int64_t distance = dx + dy;
            if (dt < distance) return "No";
            if (dt%2 != distance%2) return "No";
        }
        return "Yes";
    };

    std::cout << judge() << std::endl;

    return 0;
}

Measured memory_bytes: 4980