akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        var N = Int();
        var M = Int();
        var A = Longs();

        Array.Sort(A);


       List<Tuple<int, long>> pair = new List<Tuple<int, long>>();
        for (int i = 0; i< M; i++) {
            pair.Add(Tuple.Create(Int(), Long()));
        }
        pair.Sort((a, b) => (int)(b.Item2 - a.Item2));
        
        int tmp = 0;
        for (int i = 0; i < M; i++ ) {
            int j = pair[i].Item1;
            while(j > 0 && tmp < N && A[tmp] < pair[i].Item2) {
                A[tmp] = pair[i].Item2;
                j--;
                tmp++;
            }
        }

        long ret = 0;
        for (int i = 0; i < N; i++ ) {
            ret += A[i];
        }

        Console.WriteLine(ret);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}


Measured memory_bytes: 29912
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		for(int i = 0; i < n; i++) b[i] = sc.nextInt();
		long sumA = 0, sumB = 0;
		for(int i = 0; i < n; i++) {
			sumA += a[i];
			sumB += b[i];
		}
		long sum = sumB - sumA;
		long minA = 0, minB = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] > b[i]) minB += a[i] - b[i];
			else if(a[i] < b[i]) minA += (b[i] - a[i] + 1) / 2;
		}
		if(sum >= minA && sum >= minB) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 42772
#include <stdio.h>
#include <string.h>
int main(void){
    char a[200020];
    scanf("%s",a);
    long long z[26]={},ans=strlen(a)*(strlen(a)-1)/2;;
    for (int i=0; i<strlen(a); i++){
        z[a[i]-'a']++;
    }
    for (int i=0; i<26; i++){
        ans-=z[i]*(z[i]-1)/2;
    }
    printf("%lld\n",ans+1);
    return 0;
}

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

typedef long long int ll;

#define mod 1000000007
#define pb push_back
#define prt1(a) cout<<a<<" ";
#define prt2(a,b) cout<<a<<" "<<b<<" ";
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" ";
#define rep(i,st,end) for(int i=st;i<(int)end;i++)
#define repv(i,st,end) for(int i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

//vector<ll> adj1[21],adj2[21];
//ll roadid1[21][21],roadid2[21][21];

int main() {
	int n;
	cin>>n;
	string s,s1="",s2="";
	cin>>s;
	int len=n/2;
	for(int i=0;i<len;i++)
	s1+=s[i];
	for(int i=len;i<n;i++)
	s2+=s[i];
//	cout<<s1<<" "<<s2;
	if(s1==s2){
	    cout<<"Yes";
	}
	else
	cout<<"No";
	

	return 0;
}

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

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

using namespace std;

const int MAX = 3000;
int cave[MAX][MAX];
int toIndex[1000010];
int dp[MAX][MAX];
int dx[] = {+1,+0,-1,+0};
int dy[] = {+0,-1,+0,+1};

bool isValid(int x,int y) { return 0 <= x && x < MAX && 0 <= y && y < MAX; }

void pre_calc(){
  memset(cave,-1,sizeof(cave));
  int phase = 1;
  int x = MAX/2, y = MAX/2, dir = 0;
  while( phase <= 1000000 ){
    toIndex[phase] = x + y * MAX;
    cave[y][x] = phase++;
    x += dx[dir], y += dy[dir];
    if( cave[y+dy[(dir+1)%4]][x+dx[(dir+1)%4]] == -1 ) ( dir += 1 ) %= 4;
  }
}

const int  MAX_P = 1000010;

bool isntprime[MAX_P+1]; 	
void init(){
  isntprime[0] = isntprime[1] = true;
  int j;	
  for(int i=2;i<= MAX_P;i++)if(!isntprime[i])for(j=2*i;j<=MAX_P;j+=i)isntprime[j] = true;
}


void compute(int limit,int sp){
  memset(dp,-1,sizeof(dp));
  int sx = toIndex[sp] % MAX, sy = toIndex[sp] / MAX;
  dp[sy][sx] = !isntprime[sp];
  int maxi[2] = {0,0};
  if( dp[sy][sx] > maxi[0] ) { maxi[0] = dp[sy][sx], maxi[1] = sp; }
  REP(y,sy,MAX) rep(x,MAX) if( dp[y][x] != -1) {
    for(int dx=-1;dx<=1;dx++){
      int nx = x + dx, ny = y + 1;
      if( !isValid(nx,ny) ) continue;
      if( cave[ny][nx] > limit || cave[ny][nx] == -1 ) continue;
      dp[ny][nx] = max(dp[ny][nx],dp[y][x]+!isntprime[cave[ny][nx]]);
      if( !isntprime[cave[ny][nx]] ) {
        if( dp[ny][nx] > maxi[0] ) { maxi[0] = dp[ny][nx]; maxi[1] = cave[ny][nx]; }
        else if( dp[ny][nx] == maxi[0] ) maxi[1] = max(maxi[1],cave[ny][nx]);
      }
    }
  }
  cout << maxi[0] << " " << maxi[1] << endl;
}

int main(){
  init();
  pre_calc();
  int m,n;
  while( cin >> m >> n, m,n ) compute(m,n);
  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    bool f = true;
    if(count(all(s), 'S') != 0 && count(all(s), 'N') == 0) f = false;
    if(count(all(s), 'N') != 0 && count(all(s), 'S') == 0) f = false;
    if(count(all(s), 'W') != 0 && count(all(s), 'E') == 0) f = false;
    if(count(all(s), 'E') != 0 && count(all(s), 'W') == 0) f = false;
    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        uf.merge(x,y);
    }

    int ans=0;
    rep(i,n){
        if(uf.issame(i,p[i])) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1012
#include <stdio.h>
main(){
  int i,a[10],b[9],x;
  long long n;
  while(scanf("%lld",&n) !=EOF){
    x=1000000000;
    for(i=0;i<10;i++){
      a[i]=n/x;
      n-=(long long)a[i]*x;
      x/=10;
    }
    for(i=0;i<9;i++){
      if(a[i]+a[i+1]>=10){
	b[i]=(a[i]+a[i+1])/10;
	b[i]=a[i]+a[i+1]-b[i]*10;
      }
      else b[i]=a[i]+a[i+1];
    }
    for(i=0;i<8;i++){
      if(b[i]+b[i+1]>=10){
	a[i]=(b[i]+b[i+1])/10;
	a[i]=b[i]+b[i+1]-a[i]*10;
      }
      else a[i]=b[i]+b[i+1];
    }
    for(i=0;i<7;i++){
      if(a[i]+a[i+1]>=10){
	b[i]=(a[i]+a[i+1])/10;
	b[i]=a[i]+a[i+1]-b[i]*10;
      }
      else b[i]=a[i]+a[i+1];
    }
    for(i=0;i<6;i++){
      if(b[i]+b[i+1]>=10){
	a[i]=(b[i]+b[i+1])/10;
	a[i]=b[i]+b[i+1]-a[i]*10;
      }
      else a[i]=b[i]+b[i+1];
    }
    for(i=0;i<5;i++){
      if(a[i]+a[i+1]>=10){
	b[i]=(a[i]+a[i+1])/10;
	b[i]=a[i]+a[i+1]-b[i]*10;
      }
      else b[i]=a[i]+a[i+1];
    }
    for(i=0;i<4;i++){
      if(b[i]+b[i+1]>=10){
	a[i]=(b[i]+b[i+1])/10;
	a[i]=b[i]+b[i+1]-a[i]*10;
      }
      else a[i]=b[i]+b[i+1];
    }
    for(i=0;i<3;i++){
      if(a[i]+a[i+1]>=10){
	b[i]=(a[i]+a[i+1])/10;
	b[i]=a[i]+a[i+1]-b[i]*10;
      }
      else b[i]=a[i]+a[i+1];
    }
    for(i=0;i<2;i++){
      if(b[i]+b[i+1]>=10){
	a[i]=(b[i]+b[i+1])/10;
	a[i]=b[i]+b[i+1]-a[i]*10;
      }
      else a[i]=b[i]+b[i+1];
    }
    if(a[0]+a[1]>=10){
      b[0]=(a[0]+a[1])/10;
      b[0]=a[0]+a[1]-b[0]*10;
    }
    else b[0]=a[0]+a[1];
    
    printf("%d\n",b[0]); 
  }
  return 0;
}

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

class union_find {
	const int N; // the number of nodes
	int M; // the number of trees
	std::vector<int> parent, sz;

public :
	union_find(const int& n) : N(n), M(n), parent(n, -1), sz(n, 1) {}

	const int& root(const int& k) {return ((parent[k] == -1)?k:(parent[k] = root(parent[k])));}

	bool is_united(const int& i, const int& j) {return (root(i) == root(j));}

	bool unite(int i, int j) {
		i = root(i); j = root(j);
		if (i == j) return false;
		if (sz[i] < sz[j]) std::swap(i, j);
		sz[i] += sz[j];
		parent[j] = i;
		M--;
		return true;
	}

	const int& count_trees() const {return M;}

	const int& size(const int& k) {return sz[root(k)];}
};

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

	int N, M;
	std::cin >> N >> M;
	union_find uf(N);

	while (M--) {
		int A, B;
		std::cin >> A >> B;
		uf.unite(A - 1, B - 1);
	}
	std::cout << uf.count_trees() - 1 << '\n';
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int a, b; cin >> a >> b;
    if(b%a == 0) print(a+b);
    else print(b-a);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;
ll H[MAX_N];
ll dp[MAX_N];

void solve() {
	cin >> N >> K;
	rep(i, 0, N) cin >> H[i];
	rep(i, 0, N) dp[i] = linf;
	dp[0] = 0;
	rep(i, 0, N) {
		rep(j, 1, K + 1) {
			MIN(dp[i + j], dp[i] + abs(H[i] - H[i + j]));
		}
	}
	cout << dp[N - 1] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3072
n = int(input())
a = list(map(int, input().split()))
ans = 0
number = [ i for i in range(n+1)]
for i in range(n):
    if a[i]>n:
        ans +=1
    else:
        number[a[i]]-=1

for i in range(n):
    if number[i+1]==i+1:
        number[i+1]=0
    elif number[i+1]>0:
        number[i+1]= i+1-number[i+1]
    else:
        number[i+1]=abs(number[i+1])
    ans += number[i+1]
print(ans)

Measured memory_bytes: 64228
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e18;
ll s;
int main()
{
    scanf("%lld",&s);
    if(s==maxn)
    {
        printf("0 0 1000000000 0 0 1000000000");
    }
    else
    {
        ll x=sqrt(s+1);
        x+=1;
        if(x>1e9)
            x=1e9;
        ll t=x;
        x=x*x-s;
        printf("0 0 1 %lld %lld %lld",t,t,x);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  int h,w; cin >> h >> w;
  char s[h][w];
  rep(i,h){
    rep(j,w){
      cin >> s[i][j];
    }
  }
  int l[h][w],r[h][w],u[h][w],d[h][w];
  rep(i,h){
    rep(j,w){
      if(s[i][j] == '#') l[i][j] = 0;
      else if(j == 0) l[i][j] = 1;
      else l[i][j] = l[i][j-1]+1;
    }
  }
  rep(i,h){
    for(int j = w-1; j >= 0; j--){
      if(s[i][j] == '#') r[i][j] = 0;
      else if(j == w-1) r[i][j] = 1;
      else r[i][j] =r[i][j+1]+1;
    }
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j] == '#') u[i][j] = 0;
      else if(i == 0) u[i][j] = 1;
      else u[i][j] = u[i-1][j]+1;
    }
  }
  rep(j,w){
    for(int i = h-1; i >= 0; i--){
      if(s[i][j] == '#') d[i][j] = 0;
      else if(i == h-1) d[i][j] = 1;
      else d[i][j] = d[i+1][j]+1;
    }
  }
  int ans = 0;
  rep(i,h){
    rep(j,w){
      int count = l[i][j] + r[i][j] + u[i][j] + d[i][j] -3;
      ans = max(ans,count);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[100000];
	int saidai = 0;
	rep(i, N) saidai = max(saidai, (A[i] = getint()));
	int saishou = 1e9;
	int k;
	rep(i, N) {
		if (saishou > abs(A[i] * 2 - saidai) && A[i] != saidai) {
			saishou = abs(A[i] * 2 - saidai);
			k = A[i];
		}
	}
	cosp(saidai);
	co(k);

	Would you please return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(int i=x;i<y;i++)
#define foreI(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sl "\n";
#define ii pair<ll,ll>
#define mk make_pair


typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int MAXN = 1010;
ll dp[MAXN][MAXN];
char grid[MAXN][MAXN];
int n,m;
ll ans=0;
const int mod =1e9+7;
int main() {FIN;
   
    cin>>n>>m;
    fore(i,0,n)fore(j,0,m)cin>>grid[i][j];
    memset(dp,0,sizeof(dp));
    fore(i,0,n){if(grid[i][0]!='#')dp[i][0]=1;else break;}
     fore(i,0,m){if(grid[0][i]!='#')dp[0][i]=1;else break;}

     fore(i,1,n){
        fore(j,1,m){
            if(grid[i][j]=='.'&&i-1>-1)dp[i][j]+=dp[i-1][j]%mod;
            if(grid[i][j]=='.'&&j-1>-1)dp[i][j]+=dp[i][j-1]%mod;
        }
     }
    cout<<dp[n-1][m-1]%mod<<sl;
    return 0;
}




Measured memory_bytes: 12548
from math import*
K=int(input())
N=0
k=K*K
d1=[0]*int(k)
i=0
j=0
for b in range(K):
    for c in range(K):
        d1[i]=gcd((c+1),(b+1))
        i+=1
for a in range(K):
    for x in d1:
        N+=gcd(x,(a+1))
print(N)

Measured memory_bytes: 9264
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    { 
        int n,k;
        cin>>n>>k;
        int ans=0;
        while(n)
        {
            n=n/k;
            ans++;
        }
       cout<<ans;
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 100010;
const int maxD = 15;
const int maxH = 1010; 
const int MOD = 1000000007;

set<int> st;
int main()
{
	int n;
	scanf("%d",&n);
	set<int>::iterator it;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		it = st.find(x);
		if(it == st.end())
			st.insert(x);
		else
			st.erase(x);
	}
		int ans = st.size();
	printf("%d\n",ans);
	return 0;
}  

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

#define int ll
#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}


int32_t main() {
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			for(int k = 1; k <= n; k++)
				sum += __gcd(__gcd(i, j), k);	
		}
	}
	cout << sum;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define Mod 1000000007
int qpow(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)  res = res * a % Mod;
		a = a * a % Mod;
		b >>= 1;
	}
	return res;
}
signed main() {
	int n;
	cin >> n;
	if(n == 1)  puts("0");
	else {
		int res = 1, res2 = 1, C = n, mi = 8;
		for(int i = 1; i <= n; i++)  res = res * 10 % Mod;
		for(int i = 1; i <= n; i++) {
			res2 += C * mi % Mod;
			res2 %= Mod;
			mi = mi * 8 % Mod;
			C = C * (n - i) % Mod * qpow(i + 1, Mod - 2) % Mod;
		}
		res2 = res2 * 2 % Mod;
		res = (res - res2 + Mod) % Mod;
		res = (res + qpow(8, n)) % Mod;
		cout << res << endl;
	}
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
	}

	sort(d.begin(), d.end(), greater<int>());

	int ans = 0, temp = 0;
	for (int i = 0; i < d.size(); ++i)
	{
		if(d[i] != temp){
			ans++;
			temp = d[i];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;

void solve(long long N, std::vector<long long> h)
{

    vec dp(N, 1e+18);
    dp[0] = 0;
    for (ll i = 0; i < N; i++)
    {
        if (i + 1 < N)
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        if (i + 2 < N)
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[N - 1] << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &h[i]);
    }
    solve(N, std::move(h));
    return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_substring(void) {
	string s, t;
	cin >> s >> t;

	int s_size = s.size();
	int t_size = t.size();

	int range = s_size - t_size;

	int min = t_size;
	int match_cnt = 0;

	for (int i = 0; i <= range; i++) {
		string s_sub = s.substr(i, t_size);
		match_cnt = 0;
		for (int j = 0; j < t_size; j++) {
			if (t[j] != s_sub[j]) match_cnt++;
		}

		if (match_cnt < min) min= match_cnt;
	}

	cout << min << endl;
}

int main()
{
    b_substring();

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	int num=0;
	rep(i,3)if(s[i]=='o')num++;
	cout<<700+num*100<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    a = a + b;
    int x = std::stoi(a);
    rep(i, 1000) {
        if (x == i*i) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 764
#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 1 LL << 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,Y;cin >> N >>  Y;
    int a = -1;
    int b = -1;
    int c = -1;

    rep(i,N+1)for(int j = 0;j+i <= N;j++){
        if(i * 10000 + j * 5000 + (N-i-j) * 1000 == Y){
            a = i;
            b = j;
            c = (N-i-j);
            break;
        }
    }

    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] Y = new int[2][M];
        
        for(int i = 0; i < M; i++){
            Y[0][i] = sc.nextInt();
            Y[1][i] = sc.nextInt();
        }
        sc.close();
        int[] index  = new int[M];
        for(int i = 0; i < M; i++)
            index[i] = i;
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < M; i++){
            map.put(Y[1][i], index[i]);
        }
        Arrays.sort(Y[1]);
        int[] count = new int[N];
        for(int i = 0; i < N; i++)
            count[i] = 1;
        int[] countM = new int[M];
        for(int i = 0; i < M; i++){
            countM[map.get(Y[1][i])] = count[Y[0][map.get(Y[1][i])] -1];
            count[Y[0][map.get(Y[1][i])] -1]++;
        }
        for(int i = 0; i < M; i++){
            System.out.println(String.format("%06d%06d", Y[0][i], countM[i]));
        }
    }
}

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

int main(){
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  double maxP = -1.0;
  int maxSum;
  int maxSugar;
  for (int i = 0; 100 * A * i <= F; ++i){
    for (int j = 0; 100 * A * i + 100 * B * j <= F; ++j) {
      if (i == 0 && j == 0) continue;
      for (int k = 0; 100 * A * i + 100 * B * j + C * k <= F; ++k) {
	for (int l = 0; 100 * A * i + 100 * B * j + C * k + D * l <= F; ++l){
	  if (i == 0 && j == 0 && k == 0 && l == 0) continue;
	  int sugar = C * k + D * l;
	  int water = 100 * A * i + 100 * B * j;
	  int sum = water + sugar;
	  double p = (sugar * 100.0) / sum;
	  if ((p <= (100.0 * E) / (100.0 + E)) && p > maxP){
	      maxP = p;
	      maxSum = sum;
	      maxSugar = sugar;
	  }
	}
      }
    }
  }
  cout << maxSum << " " << maxSugar << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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();
        if(a==b && c==b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22612
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll a[200010], b[200010];
vector<ll> tree[200010];
ll p[200010], x[200010];
ll cnt[200010] = {};

void dfs(ll cur, ll par, ll d){
    cnt[cur] += d;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur, cnt[cur]);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll Q;
    cin >> Q;
    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
    }
    rep(i,0,Q){
        cin >> p[i] >> x[i];
        p[i]--;
        cnt[p[i]] += x[i];
    }
    dfs(0, -1, 0);
    rep(i,0,N){
        cout << cnt[i] << " \n"[i==N-1];
    }
    




}


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

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
    int N, K; cin >> N >> K;
    vector<int> L(K);
    vector<int> R(K);
    rep(i, K) cin >> L[i] >> R[i];

    vector<mint> dp(N+100);
    dp[1] = 1;
    for(int i = 1;i < N+1; i++){
        dp[i] += dp[i-1];
        rep(j, K){
            int l = min(L[j] + i, N+10);
            int r = min(R[j] + i, N+10);
            dp[l] += dp[i];
            dp[r+1] -= dp[i];
        }
    }
    cout << (dp[N] - dp[N-1]).x << endl;
    return 0;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(int n){
    cout << "Yes" << endl;
}

void no (int n){
    cout << "No" << endl;
}

int ggcd(int a, int b){
    int c = a % b;
    while (c > 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    if (n >= 30) yes(1);
    else no(1);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int h,w;
	cin >> h >> w;
	int a[h][w],sum_line[h] = {};
	REP(i,h){
		REP(j,w){
			cin >> a[i][j];
			sum_line[i] += a[i][j];
		}
	}
	vector<tuple<int, int, int, int>> ans;
	bool done[h][w] = {};
	REP(i,h - 1){
		if(sum_line[i] % 2 == 1){
			REP(j,w){
				if(a[i][j] > 0 && a[i][j] % 2 == 1){
					a[i][j]--;
					a[i + 1][j]++;
					ans.push_back(make_tuple(i, j, i + 1, j));
					sum_line[i + 1]++;
					done[i][j] = true;
					break;
				}
			}
		}
	}
	REP(i,h){
		REP(j,w - 1){
			if(a[i][j] % 2 == 1){
				if(done[i][j + 1] == false){
					a[i][j]--;
					a[i][j + 1]++;
					ans.push_back(make_tuple(i, j, i, j + 1));
				}else{
					a[i][j]--;
					a[i][j + 2]++;
					ans.push_back(make_tuple(i, j, i, j + 2));
				}
			}
		}
	}
	cout << ans.size() << endl;
	REP(i,ans.size()) cout << get<0>(ans[i]) + 1 << " " << get<1>(ans[i]) + 1 << " " << get<2>(ans[i]) + 1 << " " << get<3>(ans[i]) + 1 << endl;
}

Measured memory_bytes: 5488
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  string s; read(s);
  int sum = 0;
  for (char c : s) sum += c - '0';
  write(sum % 9 == 0 ? "Yes" : "No");
}



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

using namespace std;

#define LL long long
#define reg register
#define Raed Read
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

const int N=2e5+5,mod=998244353;

inline void Add(LL &x,int y) {
	x+=y;
	if(x<0)x+=mod;
	if(x>=mod)x-=mod;
}

struct point {
	int x,y;
} S[N];

struct cmpy {
	bool operator()(point _,point __)const {
		return _.y<__.y;
	}
};

int X[N];

struct BIT {
	int c[N];
	inline void clear(void) {
		memset(c,0,sizeof c);
	}
	inline void Add(int x) {
		for(; x<N; x+=x&-x)c[x]++;
	}
	inline int Sum(int x) {
		int res=0;
		for(; x; x^=x&-x)res+=c[x];
		return res;
	}
} tr;

int F2[N];

int main() {
	int n =Read();
	F2[0]=1;
	rep(i,1,n)F2[i]=(1ll*F2[i-1]<<1)%mod;
	rep(i,1,n) S[i].x=X[i]=Read(),S[i].y=Read();
	sort(X+1,X+n+1);
	rep(i,1,n)S[i].x=lower_bound(X+1,X+n+1,S[i].x)-X;
	LL Ans=1ll*n*(F2[n]-1)%mod;
	rep(i,1,n) {
		Add(Ans,-(F2[i]-2));
		Add(Ans,-(F2[n-i+1]-2));
	}
	sort(S+1,S+n+1,cmpy());
	rep(i,1,n) {
		Add(Ans,(F2[tr.Sum(S[i].x)]-1));
		Add(Ans,(F2[i-1-tr.Sum(S[i].x)]-1));
		tr.Add(S[i].x);
	}
	tr.clear();
	drep(i,n,1) {
		Add(Ans,(F2[tr.Sum(S[i].x)]-1));
		Add(Ans,(F2[n-i-tr.Sum(S[i].x)]-1));
		tr.Add(S[i].x);
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 4096
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll n, k;
vector<ll> a;

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    a.assign(n, 0);
    F0R(i, n) cin >> a[i];
    ll tot = 0;
    F0R(i, n) tot += a[i];
    ll res = 1;
    vector<ll> f;
    FOR(i, 1, sqrt(tot) + 1) if(tot%i == 0) f.pb(i), f.pb(tot/i);
    sort(f.begin(), f.end(), greater<ll>());
    F0R(i, sz(f))
    {
        if(tot%f[i] != 0) continue;
        vector<ll> b = a;
        F0R(j, sz(b)) b[j] %= f[i];
        sort(b.begin(), b.end());
        ll ttot = 0;
        F0R(j, sz(b)) ttot += b[j];
        // for(auto x : b) cout << x << " ";
        // cout << "\n";
        ll ctot = 0;
        F0R(j, sz(b) + 1) 
        {
            // cout << "tst " << b[j] << " " << i << " " << i * (sz(b) - j - 1) - b[sz(b) - 1] + b[j] << "\n";
            if(ctot == f[i] * (sz(b) - j) - ttot + ctot && ctot <= k)
            {
                cout << f[i];
                return 0;
            }
            if(j < sz(b)) ctot += b[j];
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define reset(a,b) memset(a,b,sizeof a);
#define ll int
#define MOD 3210121
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define dalam fl<=l && r<=fr
#define kiwo 2*(idx),l,MID
#define tengen 2*idx+1,MID+1,r
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 200003
#define pc(x) putchar_unlocked(x);

long long n,a[mx];
long long sum,jaw;
map<long long,long long>ma;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	ma[0]++;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		jaw+=ma[(sum+a[i])];
		sum+=a[i];
		ma[sum]++;
	}
	cout<<jaw;
}


Measured memory_bytes: 14336
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    long pos[] = new long[m];
    for(int i=0;i<m;++i)pos[i]=sc.nextLong()+sc.nextLong()*(long)(n+1);
    Arrays.sort(pos);
    int ans = 0;
    int brg = -1;
    for(int i=0;i<m;++i){
      if(brg<=pos[i]%(long)(n+1)){
        brg=(int)(pos[i]/(long)(n+1));++ans;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 84892
#include <stdio.h>

int main(void)
{
  int n;
  long long sum = 0;
  scanf("%d", &n);

  for (int i = 1; i <= n; i++)
  {
    if (i % 3 == 0 && i % 5 == 0)
    {
      continue;
    }
    else if (i % 3 == 0)
    {
      continue;
    }
    else if (i % 5 == 0)
    {
      continue;
    }
    else
    {
      sum += i;
    }
  }
  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
inline int mul( int x , int y ){ return 1LL * x * y % mod ;}
int power_mod( int x , int y ){int ret = 1;while( y ){if( y & 1 ) ret = mul( ret , x );y >>= 1;x = mul( x , x );}return ret;}
inline int read(){int 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;}
using namespace std;
const int maxn = 2e5 + 500;

char s[maxn];
int n;

const char * s1 = "dream";
const char * s2 = "dreamer";
const char * s3 = "erase";
const char * s4 = "eraser";

int dp[maxn];


int main(int argc,char *argv[]){
	scanf("%s",s+1);
	n=strlen(s+1);
	dp[0] =1 ;
	for(int i = 0 ; i < n ; ++ i)
		if( dp[i] ){
			if(memcmp(s+i+1,s1,sizeof(char)*5)==0)
				dp[i + 5] = 1;
		    if(memcmp(s+i+1,s2,sizeof(char)*7)==0)
				dp[i + 7] = 1;
			if(memcmp(s+i+1,s3,sizeof(char)*5)==0)
				dp[i + 5] = 1;
			if(memcmp(s+i+1,s4,sizeof(char)*6)==0)
				dp[i + 6] = 1;
		}
	if( dp[n] )
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int plus = a+b;
		int minus = a-b;
		int multi = a*b;
		int result = 0;
		if (plus > minus) {
			result = plus > multi ? plus : multi; 
		} else {
			result = minus > multi ? minus : multi;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  int n;cin>>n;
  repd(i,1,10){
    repd(j,1,10){
      if(i * j == n){
        cout << "Yes" << endl;return 0;
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define inf 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof a)
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 20050;
const int M = 24005;
const int mod=1e9+7;
int n,m;
char str[N];
int main(){
    int tot=0;
    int sx,sy,ex,ey;
    scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
    int x=ex-sx,y=ey-sy;
    for(int i=1;i<=y;i++)str[tot++]='U';
    for(int i=1;i<=x;i++)str[tot++]='R';
    for(int i=1;i<=y;i++)str[tot++]='D';
    for(int i=1;i<=x;i++)str[tot++]='L';
    str[tot++]='L';
    for(int i=1;i<=y+1;i++)str[tot++]='U';
    for(int i=1;i<=x+1;i++)str[tot++]='R';
    str[tot++]='D';
    str[tot++]='R';
    for(int i=1;i<=y+1;i++)str[tot++]='D';
    for(int i=1;i<=x+1;i++)str[tot++]='L';
    str[tot++]='U';
    str[tot]=0;
    printf("%s",str);
    return 0;
}


Measured memory_bytes: 256
#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 K;
ll A[101010];

ll hoge(ll v) {
	int i;
	
	FOR(i,K) v-=v%A[i];
	return v;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K;
	
	FOR(i,K) cin>>A[i];
	
	ll L=1+(1LL<<60),R=2;
	for(i=60;i>=0;i--) {
		if(hoge(L-(1LL<<i))>=2) L-=(1LL<<i);
		if(hoge(R+(1LL<<i))<=2) R+=(1LL<<i);
	}
	
	if(hoge(L)!=2 || hoge(R)!=2) return _P("-1\n");
	cout<<L<<" "<<R<<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: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int kanou(int k,int p,ll A[]){
    if(p==2){
        return k;
    }
    if(k>100002){
        return -1;
    }
    else{
        return kanou(k+1,A[p],A);
    }
}

int main(){
    ll N,A[100007];cin >> N;
    rep(i,N){
        cin >> A[i+1];
    }
    cout<< kanou(0,1,A) <<endl;
}

Measured memory_bytes: 1656