akhauriyash/Code-Regression huggingface dataset:
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,x,y,cnt[2005]={},dist[2005][2005]={};
  vector<int> e[2005];
  cin >> n >> x >> y;
  x--,y--;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      dist[i][j]=0;
    }
  }
  for(int i=0; i<n-1; i++) {
    e[i].push_back(i+1);
    e[i+1].push_back(i);
  }
  e[x].push_back(y);
  e[y].push_back(x);
  for(int i=0; i<n; i++) {
    queue<int> q;
    q.push(i);
    while(q.size()) {
      int a=q.front();
      q.pop();
      for(auto p:e[a]) {
        if(dist[i][p]!=0||i==p) {
          continue;
        }
        dist[i][p]=dist[i][a]+1;
        q.push(p);
      }
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      cnt[dist[i][j]]++;
    }
  }
  for(int i=1; i<n; i++) {
    cout << cnt[i] << "\n";
  }
}

Measured memory_bytes: 16128
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;

void main() {
    int n, m, k; scan(n, m, k);

    foreach (i ; 0 .. n + 1) {
        foreach (j ; 0 .. m + 1) {
            if ((m - j)*i + (n - i)*j == k) {
                writeln("Yes");
                return;
            }
        }
    }

    writeln("No");
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main(){
	int N;
	string S;
	cin >> N >> S;
	
	int ok=0,ng=N/2+1;
	
	while(abs(ok-ng)>1){
		int mid=(ok+ng)/2;
		unordered_map<string,int> m;
		bool flag=false;
		for(int i=0;i+mid-1<N;i++){
			string subS=S.substr(i,mid);
			if(m.count(subS)==1){
				if(i-m[subS]>=mid){
					ok=mid;
					flag=true;
					break;
				}
			}
			else m.emplace(subS,i);
		}
		if(flag)ok=mid;
		else ng=mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 6672
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
from itertools import chain
def main():
    n = int(input())
    a1 = chain(tuple([0]), tuple(map(int, input().split())))
    a2 = chain(tuple([0]), tuple(map(int, input().split())))

    a1a = tuple(accumulate(a1))
    a2a = tuple(accumulate(a2))
    r = 0
    for i1 in range(1, n + 1):
        r = max(r, a1a[i1] + a2a[n] - a2a[i1 - 1])
    print(r)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := readString()
	m := map[string]bool{
		"a": true,
		"b": true,
		"c": true,
		"d": true,
		"e": true,
		"f": true,
		"g": true,
		"h": true,
		"i": true,
		"j": true,
		"k": true,
		"l": true,
		"m": true,
		"n": true,
		"o": true,
		"p": true,
		"q": true,
		"r": true,
		"s": true,
		"t": true,
		"u": true,
		"v": true,
		"w": true,
		"x": true,
		"y": true,
		"z": true,
	}
	keys := make([]string, 0, len(m))
	for k, _ := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	for _, c := range s {
		if m[string(c)] {
			m[string(c)] = false
		}
	}
	for _, c := range keys {
		if m[c] {
			fmt.Println(c)
			os.Exit(0)
		}
	}
	fmt.Println("None")
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int main()
{
	int i,j,k,r,g,b;
	sd(r);
	sd(g);
	sd(b);
	int temp=r*100+g*10+b;
	printf("%s\n",(temp%4 == 0 )? "YES":"NO" );
	return 0;
}

Measured memory_bytes: 256
def main():
  n, k = map(int, input().split())
  
  kids = list()
  sum = 0
  
  for i in range(k):
    dustbox = input()
    kids += list(map(int, input().split()))
    
  for i in range(1, n+1):
    if i not in kids:
      sum += 1
      
  print(sum)
  
main()

Measured memory_bytes: 8864
my ($N,$K) = split(/ /,<>);
my $d;
my %data;
for(my $i=0;$i<$K;$i++){
    $d = <STDIN>;
    chomp($s = <STDIN>);
    my @dat = split(/ /,$s);
    for(my $j=0;$j<=$#dat;$j++){
        $data{$dat[$j]} = 1;
    }
}
my $count =$N;
foreach my $num (keys%data){
    $count--;
}
print "$count";


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    vector<vector<int>> A(3, vector<int>(3, 0));
    vector<vector<int>> ok(3, vector<int>(3, 0));

    rep(i, 3)rep(j, 3) cin >> A[i][j];

    int N;
    cin >> N;
    vector<int> b(N);
    rep(i, N) cin >> b.at(i);

    rep(k, N) {
        rep(i, 3)rep(j, 3) {
            if (b.at(k) == A[i][j]) ok[i][j] = 1;
        }
    }

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

Measured memory_bytes: 256
n=int(input())
ans=0

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

temp=factorization(n) 

if n==1:
  print(0)
else:
  i=0
  j=0
  while i<len(temp):
    if temp[i][1]>=j+1:
      temp[i][1]=temp[i][1]-(j+1)
      j=j+1
      ans=ans+1
    else:
      i=i+1
      j=0
  print(ans)

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a; scanf("%d", &a);
	printf("%d\n", 1-a);
}


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

int main(){
    int n;
    cin >> n;
    vector<tuple<int,int,int> > day;
    day.resize(n);
    for(int i=0;i<n;i++){
        int st,en;
        cin >> st >> en;
        day[i] = make_tuple(en-st+1, st-1, en-1);
    }
    sort(day.begin(),day.end());
    int hpdy[31]={};
    for(tuple<int,int,int>p:day){
        for(int i=get<1>(p);i<=get<2>(p);i++){
            if(hpdy[i]==0){
                hpdy[i]=1;
                break;
            }
        }
    }
    int sum=0;
    for(int i=0;i<31;i++){
        sum+=hpdy[i]+1;
    }
    cout << sum*50 << endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int n;
ll a[100000+5];
//ll dp[100000+5];
//bool check[100000+5];

int main(){
	scanf("%d", &n);
	FOR(i,1,n) scanf("%lld", a+i);
	vector<ll> v(n,-1);
	FOR(i,1,n){
		int idx = lower_bound(ALL(v), a[i]) - v.begin();
		v[idx-1] = a[i];
	}
	int ans = 0;
	FOR(i,0,n-1){
		ans += (v[i] > -1? 1:0);
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

long long dp[2020][2020];
long long sum[2020][2020];
int main() {
    int N, M;
    cin >> N >> M;
    vector<long long> S(N);
    vector<long long> T(M);
    REP(i, N) { cin >> S[i]; }
    REP(i, M) { cin >> T[i]; }
    // dp(i+1,j+1) 等しい部分列かつS[i] = T[j] が末尾であるような組み合わせ
    REP(i, 2020) {
        sum[i][0] = 1;
        sum[0][i] = 1;
    }
    long long ret = 1;
    REP(x, N) {
        REP(y, M) {
            if(S[x] == T[y]) {
                dp[x + 1][y + 1] = sum[x][y] % MOD; // xyまでの累積和
                ret += dp[x + 1][y + 1];
            }
            long long tmp = sum[x][y + 1] + sum[x + 1][y] + MOD - sum[x][y] +
                            dp[x + 1][y + 1];
            sum[x + 1][y + 1] = tmp % MOD;
        }
    }
    cout << ret % MOD << endl;
}

Measured memory_bytes: 63744
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int v = fs.nextInt(), e = fs.nextInt();
		int graph[][] = new int[v][v];
		for(int i=0;i<v;i++) {
			Arrays.fill(graph[i], INF);
		}
		for(int i=0;i<e;i++) {
			int s = fs.nextInt(), t = fs.nextInt(), d = fs.nextInt();
			graph[s][t] = d;
		}
		
		int dp[][] = new int[1<<v][v];
		for(int i=0;i<1<<v;i++) {
			Arrays.fill(dp[i],INF);
		}
		dp[(1<<v)-1][0] = 0;
		for(int i=(1<<v)-2;i>=0;i--) {
			//今いる町
			for(int j=0;j<v;j++) {
				//次にたどり着く町
				for(int k=0;k<v;k++) {
					//次にたどり着く町が、訪問済でない場合
					if((i>>k&1)==0) {
						//今の町からゴールは、次の町からゴールまでの距離に、今の町から次の町の距離の和
						dp[i][j] = Math.min(dp[i][j], dp[i|1<<k][k] + graph[j][k]);
					}
				}
			}
		}
		if(dp[0][0] == INF)System.out.println(-1);
		else System.out.println(dp[0][0]);
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 27868
from fractions import gcd
#X=b_k*(2p+1)
N,M=map(int,input().split())
b=[int(i)//2 for i in input().split()]
def v2(n):
    tmp=n
    res=0
    while(tmp>0):
        if tmp%2==0:
            tmp=tmp//2
            res+=1
        else:
            return res
def lcm(x,y):
    return x*(y//gcd(x,y))
c=[v2(i) for i in b]
if min(c)!=max(c):
    print(0)
    exit()
L=1
for i in range(N):
    L=lcm(L,b[i])
print(M//L-M//(2*L))


Measured memory_bytes: 89780
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int x,a;
  cin >> x >> a;
  if(x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}


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() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<LL> A(N);rep(i,N)cin >> A[i];
    sort(all(A));
    
    vector<LL> ct(N);
    vector<LL> ctr(N);
    LL tmp = 1;
    rep(i,N){
        if(i == 0){
            ct[0] = 1;
            tmp *= (-1);
        }
        else if(i == N-1){
            ct[N-1] = tmp;
        }
        else{
            ct[i] = 2*tmp;
            tmp *= -1;
        }
    }
    rep(i,N){
        ctr[i] = ct[i]*(-1);
    }
    sort(all(ct));
    sort(all(ctr));

    LL ans1 = 0;
    LL ans2 = 0;
    rep(i,N){
        ans1 += (ct[i]*A[i]);
        ans2 += (ctr[i]*A[i]);
    }

    LL ans = max(ans1,ans2);
    cout << ans << endl;
 
}

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

using namespace std;

int main() {
	int n;cin>>n;
	int num=1;
	while(num*num<1+8*n){
		num++;
	}
	if(num*num!=1+8*n){
		cout<<"No"<<endl;
		return 0;
	}
	if(num%2==0){
		cout<<"No"<<endl;
		return 0;
	}
	int sn=(-1+num)/2;
	int k=sn+1;
	vector<vector<int>> s(k,vector<int>(sn));
	int it=0;
	int jt=0;
	num=1;
	while(num<=n){
		for(int j=jt;j<sn;j++){
			s[it][j]=num+j-jt;
		}
		for(int i=it+1;i<k;i++){
			s[i][jt]=num+i-it-1;
		}
		num+=sn-jt;
		jt++;
		it++;
	}
	cout<<"Yes"<<endl;
	cout<<k<<endl;
	for(int i=0;i<k;i++){
		cout<<sn<<' ';
		for(int j=0;j<sn;j++){
			cout<<s[i][j]<<' ';
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	int i;
	int a[210];
	int ans;

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

	ans = 0;
	while (1)
	{
		for (i = 0;i < n;++i)
		{
			if (a[i] % 2 == 0)
				a[i] /= 2;
			else
				break;
		}
		if (i == n)
			++ans;
		else
			break;
	}

	cout << ans << endl;

	return(0);
}


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


struct edge{int to,nxt;}e[400100];

int n,m,now,fir[100100],flg[100100],ans;

queue<int>q;

void add(int x,int y)
{
	e[++now]={y,fir[x]};
	fir[x]=now;
}

void bfs()
{
	q.push(1);
	while(!q.empty())
	{
		int tt=q.front();q.pop();++ans;
		for(int i=fir[tt];i;i=e[i].nxt)
		{
			int y=e[i].to;
			if(!flg[y])flg[y]=tt,q.push(y);
		}
	}
}

main()
{
    int t1,t2;
    cin >> n >> m;
	for(int i=1;i<=m;++i)
	{
        cin >> t1 >> t2;
		add(t1,t2);add(t2,t1);
	}
	flg[1]=1;
	bfs();
	if(ans!=n)
		puts("No");
	else
	{
		puts("Yes");
		for(int i=2;i<=n;++i)printf("%d\n",flg[i]);
	}
	return 0;
}


Measured memory_bytes: 7652
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {



    double r;

    cin >> r;
    
    double menseki,ensyu;
    
    menseki = r*r*M_PI;
    ensyu = 2*r*M_PI;
  
    printf("%.6lf %.6lf\n", menseki,ensyu);
//    cout << menseki << " " << ensyu << endl;
    
    
    return 0;
    
}



Measured memory_bytes: 3288
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;
    int mod = 1000000007;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] cnts = new int[N + 1];

        for (int n = 1; n <= N; n++)
        {
            int tmp = n;

            for (int p = 2; p <= N; p++)
            {
                while (tmp % p == 0)
                {
                    tmp /= p;
                    cnts[p]++;
                }
            }
        }

        long ans = 1;
        for (int i = 2; i <= N; i++)
        {
            ans *= (cnts[i] + 1);
            ans %= mod;
        }

        Console.WriteLine(ans);

    }

    private bool isprime(int n)
    {
        if (n <= 1) return false;
        if (n == 2) return true;
        for(int i = 2;i<= Math.Sqrt(n); i++)
        {
            if (n % i == 0) return false;
        }
        return true;
     }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2648
//
//  main.cpp
//  backToProblemSolving
//
//  Created by Khaled Abdelfattah on 6/27/17.
//  Copyright © 2017 Khaled Abdelfattah. All rights reserved.
//

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

typedef long long ll;
#define MAX 1000000000
#define BASE1 23
#define BASE2 31
#define MOD1 1000000007
#define MOD2 217645177
#define eps 1e-6

int main() {
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    int arr[105 * 105];
    for (int i = 0; i < n; i ++)
        cin >> arr[i];
    int idx = 1, flag = arr[idx - 1];
    int grid[h][w];
    for (int i = 0; i < h; i += 2) {
        for (int j = 0; j < w; j ++) {
            grid[i][j] = idx;
            flag --;
            if (!flag) {
                idx ++;
                if (idx == n + 1)
                    break;
                flag = arr[idx - 1];
            }
        }
        if (i + 1 == h)
            break;
        for (int j = w - 1; j >= 0; j --) {
            grid[i + 1][j] = idx;
            flag --;
            if (!flag) {
                idx ++;
                if (idx == n + 1)
                    break;
                flag = arr[idx - 1];
            }
        }
    }
    for (int i = 0; i < h; i ++) {
        for (int j = 0; j < w; j ++)
            cout << grid[i][j] << " ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int counter;

  if((N - 1) % (K - 1) == 0){
    counter = (N - 1) / (K - 1);
  }else{
    counter = (N - 1) / (K - 1) + 1;
  }

  cout << counter << endl;

  
    
}

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

int main() {
  int n;
  cin >> n;
  while (n--) {
    int a[3];
    for (int i = 0; i < 3; i++) {
      cin >> a[i];
    }
    sort(a, a + 3);
    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

template<typename T, bool isMin>
struct ConvexHullTrick{
  #define F first
  #define S second
  using P = pair<T, T>;
  deque<P> H;

  bool empty()const{return H.empty();}
  void clear(){H.clear();}

  inline Int sgn(T x){return x == 0?0:(x<0? -1:1);}
  using D = long double;
  inline bool check(const P &a, const P &b, const P &c){
    if(b.S == a.S || c.S == b.S)
      return sgn(b.F - a.F) * sgn(c.S - b.S) >= sgn(c.F - b.F) * sgn(b.S - a.S);

    return
      D(b.F - a.F) * sgn(c.S - b.S)/D(abs(b.S - a.S)) >=
      D(c.F - b.F) * sgn(b.S - a.S)/D(abs(c.S - b.S));
  }

  void addLine(T m, T b){
    if(!isMin) m *= -1, b *= -1;
    P line(m, b);
    if(empty()){
      H.emplace_back(line);
      return;
    }

    if(H.front().F <= m){
      if(H.front().F == m){
        if(H.front().S <= b) return;
        H.pop_front();
      }
      while(H.size() >= 2 && check(line, H.front(), H[1])) H.pop_front();
      H.emplace_front(line);
    }else{
      assert(m <= H.back().F);
      if(H.back().F == m){
        if(H.back().S <= b) return;
        H.pop_back();
      }
      while(H.size() >= 2 && check(H[H.size() - 2], H.back(), line)) H.pop_back();
      H.emplace_back(line);
    }
  }

  inline T getY(const P &a, const T &x){
    return a.F * x + a.S;
  }

  T query(T x){
    assert(!empty());
    Int l = -1, r = H.size() - 1;
    while(l + 1 < r){
      Int m = (l + r) >> 1;
      if(getY(H[m], x) >= getY(H[m+1], x)) l = m;
      else r = m;
    }
    if(isMin) return getY(H[r], x);
    return - getY(H[r], x);
  }

#undef F
#undef S
};

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

  Int n;
  cin>>n;

  Int zx,zv;
  cin>>zx>>zv;

  vector<Int> xs(n),vs(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>vs[i];

  for(Int i=0;i<n;i++){
    xs[i]-=zx;
    vs[i]-=zv;
  }

  using D = double;
  const D INF = 1e10;
  vector<D> ans(n,INF);
  for(Int i=0;i<n;i++){
    if(xs[i]==0) ans[i]=0;
    if((D)xs[i]*(D)vs[i]<0) chmin(ans[i],-(D)xs[i]/(D)vs[i]);
  }

  for(Int uku=0;uku<2;uku++){
    for(Int i=0;i<n;i++){
      xs[i]*=-1;
      vs[i]*=-1;
    }

    using P = pair<D, D>;
    vector<P> vp;
    Int sp=0;
    for(Int i=0;i<n;i++){
      if(xs[i]>=0) continue;
      if(vs[i]<=0) continue;
      vp.emplace_back(vs[i],xs[i]);
      chmax(sp,vs[i]);
    }
    if(vp.empty()) continue;

    sort(vp.begin(),vp.end());
    ConvexHullTrick<D, false> cht;
    for(auto p:vp) cht.addLine(p.first,p.second);

    for(Int i=0;i<n;i++){
      if(xs[i]<=0) continue;
      if(sp<=vs[i]) continue;
      D L=0,R=INF;
      for(Int k=0;k<80;k++){
        D M=(L+R)/2;
        if(cht.query(M)>=(D)vs[i]*M+(D)xs[i]) R=M;
        else L=M;
      }
      chmin(ans[i],R);
    }
  }

  cout<<fixed<<setprecision(12);
  for(Int i=0;i<n;i++){
    if(ans[i]>=INF) cout<<-1<<"\n";
    else cout<<ans[i]<<"\n";
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 11616
#include <iostream>
#include <cstdlib>
using namespace std;
int ret[2000]={};
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    int ans;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            ans=min(min(abs(j-i),abs(x-i)+1+abs(y-j)),abs(y-i)+1+abs(x-j));
            ret[ans]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<ret[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    int N;
    input(N);
    vector<int> a(N, 0);
    input(a);

    bool res = true;
    rep(i, 0, N)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 == 0 || a[i] % 5 == 0)
            {
                continue;
            }
            else
            {
                res = false;
                break;
            }
        }
    }

    cout << (res ? "APPROVED" : "DENIED") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int s=sc.nextInt();
    int w=sc.nextInt();
    if(s>w){
      System.out.println("safe");
    }else{
      System.out.println("unsafe");
    }
  }
}


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

using namespace std;

const int N = 1e5 + 5;

int dist[N][2], n;

struct state {
    int dist, type;
    state (int dist = 0, int type = 0): dist(dist), type(type) {}
};

void bfs(){
    memset(dist, 0x3f, sizeof(dist)); dist[0][0] = 0;
    queue <state> q; q.push(state(0, 0));
    while (!q.empty()) {
        state val = q.front(); q.pop();
        int u = val.dist, type = val.type;
        //cout << u << " " << type << " " << str << "\n";
        for (int i = 0; i < 10; i++) {
            if (!i && !type) continue;
            if (dist[(u * 10 + i) % n][1] > dist[u][type] + i) {
                dist[(u * 10 + i) % n][1] = dist[u][type] + i;
                q.push(state((u * 10 + i) % n, 1));
            }
        }
    }

    cout << dist[0][1];
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    bfs();
    return 0;
}


Measured memory_bytes: 3968
#include<stdio.h>
#include<string.h>
int main()
{
    char s1[10],s2[10]="SUN";
    int n,i;
    gets(s1);
    n=strcmp(s1,s2);
    if(n==0){
        printf("7\n");
    }
    else{
        i=strcmp(s1,"SAT");
        if(i==0){
            printf("1\n");
        }
        i=strcmp(s1,"FRI");
        if(i==0){
            printf("2\n");
        }
        i=strcmp(s1,"THU");
        if(i==0){
            printf("3\n");
        }
        i=strcmp(s1,"WED");
        if(i==0){
            printf("4\n");
        }
        i=strcmp(s1,"TUE");
        if(i==0){
            printf("5\n");
        }
        i=strcmp(s1,"MON");
        if(i==0){
            printf("6\n");
        }

    }
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String cnt;

		while ((cnt = parseStdin()) != null) {
			long	avr = 0;
			int	max = Integer.parseInt(cnt);

			for (int i = 0; i < max; i++) {
				avr += parseCnt();
			}
			avr = (max > 1) ? avr / (long)max : avr;

			System.out.println(avr);
		}
	}
 
	private static int parseCnt() {
		int     cnt = 0;
		String  str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}
 
	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) stdin = tmp;
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 22760
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
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>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll n;
ll check(ll val)
{
    if((n%val)==1)
        return 1;
    ll temp=n;
    while((temp%val)==0)
        temp/=val;
    if((temp%val)==1)
        return 1;
    else
        return 0;
}
void solve()
{
    cin>>n;
    ll temp=n-1;
    vl fact,fact2;
    for(ll i=1;i*i<=n;i++)
    {
        if((n%i)==0)
        {
            fact.pb(i);
            if(i!=(n/i))
                fact.pb(n/i);
        }
    }
    for(ll i=1;i*i<=temp;i++)
    {
        if((temp%i)==0)
        {
            fact2.pb(i);
            if(i!=(temp/i))
                fact2.pb(temp/i);
        }
    }
    set <ll> ans;
    for(auto it:fact)
    {
        if(it==1)
            continue;
        // cout<<it<<'\n';
        int flag=check(it);
        if(flag==1)
            ans.insert(it);
    }
    for(auto it:fact2)
    {
        if(it==1)
            continue;
        // cout<<it<<'\n';
        int flag=check(it);
        if(flag==1)
            ans.insert(it);
    }
    cout<<ans.size()<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12160
/** 
 * THIS IS CFMASTER'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<deque<char>> s(2);
  string inp;
  cin >> inp;
  for (char c : inp) {
    s[0].push_back(c);
  }
  s[1] = s[0];
  reverse(s[1].begin(), s[1].end());
  int cur = 0;
  int tt;
  cin >> tt;
  while (tt--) {
    int q;
    cin >> q;
    if (q == 1) {
      cur ^= 1;
    } else {
      int f;
      cin >> f;
      char c;
      cin >> c;
      if (f == 1) {
        s[cur].push_front(c);
        s[cur ^ 1].push_back(c);
      } else {
        s[cur].push_back(c);
        s[cur ^ 1].push_front(c);
      }
    }
  }
  for (char c : s[cur]) {
    cout << c;
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+10;
int n,m,a[maxn],chafen[maxn],vis[maxn],ps1[maxn],ps2[maxn];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n-1;i++){
		int s=a[i],t=a[i+1];
		if(t>s){
			sum+=t-s;
			++vis[s+1];
			--vis[t+1];
			chafen[s+1]+=s+1;
			chafen[t+1]-=s+1;
		}else{
			sum+=m-s+t;
			++vis[s+1];
			++vis[1];
			--vis[t+1];
			chafen[s+1]+=s+1;
			chafen[1]-=m-s-1;
			chafen[t+1]+=m-s-1;
		}
	}
	for(int i=1;i<=m;i++){
		ps1[i]=ps1[i-1]+vis[i];
	}
	for(int i=1;i<=m;i++){
		ps2[i]=ps2[i-1]+chafen[i];
	}
//	for(int i=1;i<=m;i++){
//		cout<<ps1[i]<<" ";
//	}
//	cout<<endl;
//	for(int i=1;i<=m;i++){
//		cout<<ps2[i]<<" ";
//	}
//	cout<<endl;
	int mx=0;
	for(int i=1;i<=m;i++){
		mx=max(mx,i*ps1[i]-ps2[i]);
	}
	cout<<sum-mx<<endl;
	return 0;
}

Measured memory_bytes: 7572
n=int(input())
a=list(map(int,input().split()))
ans=0
anum={}
for i in range(n):
    ans+=a[i]
    if a[i] in anum:
        anum[a[i]]+=1
    else:
        anum[a[i]]=1
q=int(input())

for i in range(q):
    b,c=map(int,input().split())
    if b in anum:
        ans+=(c-b)*anum[b]
        if c in anum:
            anum[c]+=anum[b]
        else:
            anum[c]=anum[b]
    anum[b]=0
    print(ans)

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

int main(){
	int n, a = 100000;
	cin >> n;
	for(int i = 0;i < n;i++){
		a *= 1.05;
		if(a%1000 != 0)a += 1000 - a%1000;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi   = vector<int>;
using vll  = vector<long long>;
using vvll  = vector<vll>;
using vvi  = vector<vi>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;

int main() {
    int N; cin >> N; 
    if(N % 1000 == 0) cout << 0;
    else cout << 1000 - (N % 1000);

}

Measured memory_bytes: 3572
N = int(input())
AB = []
for i in range(N):
    A,B = map(int,input().split())
    AB.append([A,B])
AB.sort(key=lambda x: x[1])


now = 0
for i in range(N):
    A,B = AB[i]
    if now+A <= B:
        now += A
    else:
        now = -1
        break
if now == -1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 84568
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a, b, t;
	cin >> a >>b >> t;
	for(int i = 1 ; i <=t; i++){
		if(i%a==0) ans+=b;
	}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int q;cin >>q;
    multiset<ll>s;
    s.insert(-INFll);
        ll sub=0;
        ll ans=0;auto it=s.begin();
    for (int i = 0; i < q; ++i) {
        int c;cin >>c;
        if(c==1){
            ll a,b;cin >>a>>b;
            sub+=b;
            s.insert(a);
            if(s.size()==2){
                it++;//ok
            }
            else {
                if (s.size() % 2 == 1) {
                    ans += abs(a - *it);
                    if (*it>a) {
                        it--;
                    }
                } else {
                    if (*it<=a)it++;
                    ans += abs(a - *(it));
                    }
            }
        }
        else {
            cout <<*it<<" "<<ans+sub<<endl;
        }
    }
}


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

int main(){
	int n,k,t;
	vector<int> b;
	while(cin >> n >> k && n || k){
		bool f=false;
		b.clear();
		for(int i=0;i<k;i++){
			cin >> t;
			b.push_back(t);
		}
		
		for(int i=0;i<n;i++){
			for(int i=0;i<k;i++){
				cin >> t;
				b[i]-=t;
				if(b[i]<0)f=1;
			}
		}
		cout << (f ? "No" : "Yes") << endl;
	}
}

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

typedef long long LL ;
typedef pair < int , int > pii ;

#define clr( a , x ) memset ( a , x , sizeof a )

const int MAXN = 100005 ;

struct Node {
	int v , f , i ;
	Node () {}
	Node ( int v , int f , int i ) : v ( v ) , f ( f ) , i ( i ) {}
	bool operator < ( const Node& a ) const {
		return v < a.v ;
	}
} ;

Node op[MAXN << 1] ;
int px[MAXN] , py[MAXN] ;
int r[MAXN] , c[MAXN] ;
int n , m ;

int F ( int p[] , int x ) {
	return p[x] == x ? x : ( p[x] = F ( p , p[x] ) ) ;
}

void solve () {
	for ( int i = 0 ; i <= n ; ++ i ) {
		px[i] = i ;
	}
	for ( int i = 0 ; i <= m ; ++ i ) {
		py[i] = i ;
	}
	int c = 0 , v ;
	for ( int i = 0 ; i < n ; ++ i ) {
		scanf ( "%d" , &v ) ;
		op[c ++] = Node ( v , 0 , i ) ;
	}
	for ( int i = 0 ; i < m ; ++ i ) {
		scanf ( "%d" , &v ) ;
		op[c ++] = Node ( v , 1 , i ) ;
	}
	int cntx = n + 1 ;
	int cnty = m + 1 ;
	sort ( op , op + c ) ;
	LL ans = 0 ;
	for ( int i = 0 ; i < c ; ++ i ) {
		if ( op[i].f == 0 ) {
			int x = F ( px , op[i].i ) ;
			int y = F ( px , op[i].i + 1 ) ;
			if ( x == y ) continue ;
			ans += 1LL * cnty * op[i].v ;
			px[x] = y ;
			cntx -- ;
			//printf ( "ok 1 %lld\n" , ans ) ;
		} else {
			int x = F ( py , op[i].i ) ;
			int y = F ( py , op[i].i + 1 ) ;
			if ( x == y ) continue ;
			ans += 1LL * cntx * op[i].v ;
			py[x] = y ;
			cnty -- ;
			//printf ( "ok 2 %lld\n" , ans ) ;
		}
	}
	printf ( "%lld\n" , ans ) ;
}

int main () {
	while ( ~scanf ( "%d%d" , &n , &m ) ) solve () ;
	return 0 ;
}

Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int H, W, N;
	cin >> H >> W >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	int h = 0, w = 0;
	vector<vector<int>>ans(H, vector<int>(W));
	bool flag = true;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < a[i]; j++) {
			ans[h][w] = i + 1;
			if (flag) {
				w++;
				if (w == W) {
					h++;
					w--;
					flag = !flag;
				}
			}
			else {
				w--;
				if (w == -1) {
					h++;
					w++;
					flag = !flag;
				}
			}
		}
	}
	rep(i, H) {
		rep(j, W) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

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

lli n, m;

int main(void){
	cin >> n >> m;
	vector<lli> a(n+1, 1);
	vector<bool> ans(n+1);
	ans[1] = true;
	rep(k, m){
		lli x, y;
		cin >> x >> y;
		if(ans[x]){
			if(a[x] < 2){
				ans[x] = false;
			}
			ans[y] = true;
		}
		a[x]--;
		a[y]++;
	}
	lli ret = 0;
	for(int i = 1; i <= n; i++) if(ans[i]) ret++;
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3960
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N;
	cin >> N;
	vector<long>A(N);
	vector<long>ans(1000000, 0);
	for (long i = 0; i < N; i++) {
		cin >> A.at(i);
		ans.at(A.at(i))++;
		if (A.at(i) > 0) ans.at(A.at(i) - 1)++;
		ans.at(A.at(i) + 1)++;
	}
	sort(ans.begin(), ans.end(), greater<long>());
	cout << ans.at(0) << endl;
}

Measured memory_bytes: 8832
/* ITP1_8_D */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define CAN_CREATE 1
#define CAN_NOT_CREATE 0

#define MAX_LENGTH 101

/* ??????????????????????????????????????????????????´??¢?????? */
void adjust(char string[]);
/* ?????????p???????????????????????§?????? */
short do_check_create(char s[], char p[]);
/* ??????????????´????????????????????§?????? */
short is_match(char s, char p);

int main(void)
{
	char s[MAX_LENGTH], p[MAX_LENGTH];
	
	short ii;
	
	// ?????????
	for( ii = 0; ii < MAX_LENGTH; ii++ )
	{
		s[ii] = '\0';
		p[ii] = '\0';
	}
	
	// ??\????????????
	scanf("%s", s);
	scanf("%s", p);
	
	// ??\??????????????????????????????????????????
	adjust(s);
	adjust(p);

	if( do_check_create(s, p) )
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

/* ??????????????????????????????????????????????????´??¢ */
void adjust(char string[])
{
	short ii = 0;
	for( ii = 0; '\0' != string[ii]; ii++ )
	{
		if( '\n' == string[ii] )
		{
			string[ii] = '\0';
		}
	}
}

/* ?????????p???????????????????????§?????? */
short do_check_create(char s[], char p[])
{
	short ii, jj;
	
	char scat[MAX_LENGTH * 2];
	for( ii = 0; ii < MAX_LENGTH * 2; ii++ )
	{
		scat[ii] = '\0';
	}
	// 1??¨???????¢?????????????????????????????????£?????????
	strcat(scat, s);
	strcat(scat, s);
	
	short result = CAN_NOT_CREATE, temp_match = 0, kk = 0;
	ii = 0, jj = 0;
	
	while( '\0' != scat[ii] )
	{
		if( scat[ii] == p[0] )
		{
			// ?????´??????????????????????????§??????????????????
			for(jj = ii, kk = 0; scat[jj] == p[kk];jj++, kk++);
			
			// ???????????????????????????p[kk]????????????????????´???????????´????????????
			if(p[kk] == '\0')
			{
				return CAN_CREATE;
			}
		}
		ii++;
	}
	
	return CAN_NOT_CREATE;
}

/* ??????????????´????????????????¢???? */
short is_match(char s, char p)
{
	if( s == p )
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

Measured memory_bytes: 524
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define maxn 25
#define maxm 25
using namespace std;
typedef long long ll;

template <typename T> void read(T &t)
{
	t=0;int f=0;char c=getchar();
	while(!isdigit(c)){f|=c=='-';c=getchar();}
	while(isdigit(c)){t=t*10+c-'0';c=getchar();}
	if(f)t=-t;
}

int n,m,c;
int a[maxm],b[maxm];
int ans;

int main()
{
	read(n),read(m),read(c);
	for(register int i=1;i<=m;++i)read(b[i]);
	while(n--)
	{
		for(register int i=1;i<=m;++i)read(a[i]);
		int sum=0;
		for(register int i=1;i<=m;++i)
			sum+=a[i]*b[i];
		sum+=c;
		ans+=(sum>0);
	}
	printf("%d",ans);
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll maxi = -INFLONG;
    chmax(maxi,a*c);
    chmax(maxi,a*d);
    chmax(maxi,b*c);
    chmax(maxi,b*d);
    cout << maxi << endl;
}

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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char smax(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char smin(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 4000 + 7;
const int P = 998244353;

int n, k;
int C[N][N];

inline int smod(int x) { return x >= P ? x - P : x;}
inline void sadd(int &x, int y) { x += y; x >= P ? x -= P : x; }
inline void ycl(int n) {
	C[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= i; ++j) C[i][j] = smod(C[i - 1][j] + C[i - 1][j - 1]);//, dbg("C(%d, %d) = %d\n", i, j, C[i][j]);
	}
}

inline int calc(int n, int i, int k) {
	int ans = 0;
	int lim = std::min(i - 1, k) - (i / 2 + 1) + 1, ss = k - (lim << 1), mul = 1;
//	dbg("i = %d, k = %d, lim = %d\n", i, k, lim);
	for (int j = 0; j <= lim; ++j) {
		sadd(ans, (ll)C[lim][j] * C[n + ss - 1][j + ss - 1] % P * mul % P);
//		dbg("W: i = %d, ans = %d\n", i, ans);
		mul = smod(mul << 1);
	}
	return ans;
}

inline void work() {
	ycl(n + k);
	for (int i = 2; i <= (k << 1); ++i)
		if (i & 1) printf("%d\n", calc(n, i, k));
		else printf("%d\n", smod(calc(n, i - 1, k - 1) + calc(n - 1, i - 1, k - 1)));
}

inline void init() {
	read(k), read(n);
}

int main() {
#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
#endif
	init();
	work();
	fclose(stdin), fclose(stdout);
	return 0;
}

Measured memory_bytes: 61440
n = int(input())
a = list(map(int, input().split()))
num_map = dict()
for i in range(n):
    if a[i] not in num_map:
        num_map[a[i]] = 1
    else:
        num_map[a[i]] += 1

keys = sorted(list(num_map.keys()), reverse=True)

two_over = []
counter = 0
res = 1
for i in keys:
    if num_map[i] >= 4:
        res *= i ** (2 - counter)
        counter += 2
    elif num_map[i] >= 2:
        counter += 1
        res *= i
    if counter >= 2:
        print(res)
        break
else:
    print(0)


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

int main() {
  long long a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  int kyori=abs(a-b);
  int sa=v-w;
  if(kyori <=sa*t)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3636