akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) R s[i];
  rep(i,n) {
    rep(j,m) {
      if(s[i][j]=='#') continue;
      int c=0;
      rep(k,8) {
        int x=i+dx[k],y=j+dy[k];
        if(check(n,m,x,y)&&s[x][y]=='#') c++;
      }
      s[i][j]=(char)(c+'0');
    }
  }
  rep(i,n) pr(s[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
const int N = 1e5 + 7;

int cntDivs(int x) {
	int cnt = 0;
	for (int i = 1; i*i <= x; i++) {
		if (x%i == 0) {
			if (x/i == i) {
				cnt++;
			}
			else {
				cnt += 2;
			}
		}
	}
	return cnt;
}

int main() {
	fastIO;
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i < n; i++) {
		cnt += cntDivs(n-i);
	}
	cout << cnt;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=5000000000000000000;
const ll mod=1000000007;
const ll mod2=998244353;
ll dp[(1<<21)+5];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
dp[0]=1;
int n;cin>>n;
vector<vector<int>> a(n,vector<int>(n));
for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
for(int S=1;S<(1<<n);S++){
    int i=__builtin_popcount(S);
    for(int j=0;j<n;j++)if((S&(1<<j))&&a[i-1][j]==1)(dp[S]+=+dp[S^(1<<j)])%=mod;
}  
cout<<dp[(1<<n)-1]<<endl;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
struct threeElements{
int _1st,_2nd,_3rd;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    int n;
    cin>>n;
    int a[200009];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            ans+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    cout<<ans;

}


Measured memory_bytes: 4444
n = int(input())
d = sorted([int(input()) for k in range(n)], reverse=True)
dp = [0 for _ in range(n)]

for i in range(n):
	found = False
	for j in reversed(range(i)):
		if d[j] > d[i]:
			dp[i] = dp[j] + 1
			found = True
			break
	if not found:
		dp[i] = 1
print(max(dp))

Measured memory_bytes: 39024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N, K;
double ans = 0;

int main() {
	cout << fixed << setprecision(12);
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		ll box = i;
		ll counter = 0;
		while (box < K) {
			box *= 2;
			counter++;
		}
		ans += pow(0.5, (double)counter) / N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import re
s = input()
subs = re.sub('BC', 'X', s)

answer = 0
A = 0
for i in range(len(subs)):
    if subs[i] == 'A' :
        A += 1
    elif subs[i] == 'X':
        answer += A
    else:
        A = 0
print(answer)

Measured memory_bytes: 5480
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
long long counta=0;
long long countb=0;
for(long long i=0;i<s.size();i++){
  if(s[i]=='A'){
    counta++;
  }
  else{
    countb++;
  }
}
if(counta>0&&countb>0){
  cout<<"Yes"<<endl;
}
else{
  cout<<"No"<<endl;
}

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define int long long
#define ALL(A) A.begin(),A.end()
using vi=vector<int>;
using vii=vector<vi>;
signed main(){
  string S;
  int N,count=0;
  cin>>S>>N;
  int X;
  rep(i,0,S.size()){
    X=i;
    if(S.at(i)=='1')
      count++;
    else
      break;
    }
  if(count>=N)
    cout<<"1"<<endl;
  else
    cout<<S.at(X)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), A, B;
        if (N == 1) System.out.print("Hello World");
        else {
            A = sc.nextInt();
            B = sc.nextInt();
            System.out.print(A + B);
        }
        sc.close();
    }
}

Measured memory_bytes: 25172
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000;
char cn[CM + 10], * ci = cn + 10, ct, c, * owa = cn + CM;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	swap(c, ci[8]);
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	swap(c, ci[8]);
	ci += (64 - dig >> 3) + 1;

	if (ci - owa > 0) {
		memcpy(cn, owa, 10);
		ci -= CM;
		fread(cn + 10, 1, CM, stdin);
	}
	return tmp;
}
//inline int getint() {
//	int A = 0;
//	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
//	
//	if (ci - owa > 0) {
//		memcpy(cn, owa, 20);
//		ci -= 119980;
//		fread(cn + 20, 1, 119980, stdin);
//	}
//
//	return A;
//}

char* di = cn;
const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 6 + 10];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
inline void putint(ll X) {
	int ue = X / 100000;
	if (ue) {
		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
		int sita = X - ue * 100000ll;
		rep(i, 5 - f.K[sita + 1] + f.K[sita])* di++ = '0';
		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

int B[200010];

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


	fread(ci, 1, CM, stdin);

	int N = getint();
	ll kotae = 0;
	int A[200000];
	rep(i, N) kotae += B[(A[i] = getint())]++;
	int i = 0;
	
	int amari = N % 10800;
	int shou = N / 10800;
	rep(j, shou) {
		rep(k, 10800) putint(kotae - B[A[i++]] + 1);
		fwrite(cn, 1, di - cn, stdout);
		di = cn;
	}
	rep(k, amari) putint(kotae - B[A[i++]] + 1);
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3712
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int n;
    cin >> n;
    int a[n+2];
    ll sum=0;
    a[0]=0;
    a[n+1]=0;
    rep2(i,n){
        cin >> a[i];
        sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]);
    rep2(i,n){
        ll ans=sum-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.*;

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

        for(int i = 1; i <= 1000; i++) {
            if((int) (i*0.08) == A && (int) (i*0.10) == B) {
                System.out.println(i);
                System.exit(0);
            }
        }
        System.out.println(-1);
        sc.nextLine();
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N, K;
    long long int ans = 0;

    cin >> N >> K;

    int H[N];

    for (int i = 0; i < N; i++) {
        cin >> H[i];
        ans += H[i];
    }

    sort(H, H+N, greater<int>());

    if(N < K){
        cout << "0" << endl;
        exit(0);
    }

    for (int i = 0; i < K; i++){
        ans -= H[i];
    }

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


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

#define int long long

struct Combination
{
  int mod;
  vector<int> mfact;
  vector<int> rfact;

  /*
    constructor : O(sz+log(mod))    
   */
  Combination(int sz, int mod) : mfact(sz+1), rfact(sz+1), mod(mod) {
    mfact[0] = 1;
    for ( int i = 1; i < (int)mfact.size(); i++ ) {
      mfact[i] = mfact[i-1]*i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      rfact[i] = rfact[i+1]*(i+1) % mod;
    }
  }

  int fact(int k) const {
    return (mfact[k]);
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int inv(int x) const {
    return (pow(x, mod - 2));
  }

  /*
    permutation
   */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return (mfact[n]*rfact[n-r] % mod);
  }

  /*
    combination
   */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return (mfact[n]*rfact[r]%mod * rfact[n-r]%mod);    
  }  

  /*
    combination with repetition
   */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return (0);
    return (r == 0 ? 1 : C(n+r-1, r));
  }

  /*
    stirling number
   */
  int S(int n, int r) const {
    int ret;
    for ( int i = 1; i <= r; i++ ) {
      
    }
  }

  /*
    bell number
   */
  int B(int n, int r) const {

  }
};

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

  int n, k;
  cin >> n >> k;

  int MOD = 1e9+7;  
  Combination c(1000, MOD);
  int ans = 0;
  for ( int i = 1; i <= k; i++ ) {
    int add = c.C(k, i) * c.pow(i, n);
    if ( (k-i)%2 ) add *= -1;
    ans += MOD*MOD;    
    ans += add;    
    ans %= MOD;    
  }

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



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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 printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll N;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> N;
	rep(h, 1, 3500){
		rep(n, 1, 3500){
			ll a = h*n*N;
			ll b = 4*h*n - (h+n)*N;
			if(b > 0 && a%b == 0){
				cout << h << " " << n << " " << a/b << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

vector<int> ps[10];

bool f(const vector<int>& l, const vector<int>& r) {
    int sum = 0;
    for (size_t i = 0; i < l.size(); ++i) {
        auto x = l[i] - r[i];
        sum += x * x;
    }
    auto n = static_cast<size_t>(std::sqrt(sum) + 0.0001);
    for (size_t i = 1; i <= n; ++i) {
        if (i * i == sum)
            return true;
    }
    return false;
}

int main() {
    size_t n, d;
    cin >> n >> d;
    for (size_t i = 0; i < n; ++i) {
        ps[i] = vector<int>(d);
        for (size_t j = 0; j < d; ++j) {
            cin >> ps[i][j];
        }
    }
    int c = 0;
    for (size_t i = 0; i < n; ++i) {
        for (size_t j = i + 1; j < n; ++j) {
            if (f(ps[i], ps[j]))
                ++c;
        }
    }
    std::cout << c << std::endl;
    return 0;
}

Measured memory_bytes: 256
class Node
  attr_accessor :key, :left, :right, :parent
  def initialize key
    @key = key
  end
   
  def inorder
    left.inorder if left
    print " #{key}"
    right.inorder if right
  end
   
  def preorder
    print " #{key}"
    left.preorder if left
    right.preorder if right
  end
end
   
def insert
  z = Node.new($key.to_i)
  x = $root
  while x
    y = x
    x = z.key < x.key ? x.left : x.right
  end
   
  unless y
    $root = z
  else
    z.key < y.key ? y.left = z : y.right = z
    z.parent = y
  end
end
 
def find(x)
  y = $root
  while y
    return y if y.key == x
    z = y
    y = x < y.key ? y.left : y.right
  end
  return nil
end
 
def delete(x)
  y = find(x)
  z = position(y)
  if y.right.nil? || y.left.nil? then delete2(y,z)
  else
    p = y.right
    while p
      break if p.left == nil
      p = p.left
    end
    y.key = p.key
    z = position(p)
    delete2(p,z)
  end
end
 
def position(n)
  n.parent.right && n.parent.right.key == n.key
end
 
def delete2(y,z)
  if y.left.nil? && y.right.nil?
    z ? y.parent.right = nil : y.parent.left = nil
  elsif y.left.nil?
    if z 
      y.parent.right = y.right
      y.parent.right.parent = y.parent
    else
      y.parent.left = y.right
      y.parent.left.parent = y.parent
    end
  elsif y.right.nil?
    if z
      y.parent.right = y.left
      y.parent.right.parent = y.parent
    else
      y.parent.left = y.left
      y.parent.left.parent = y.parent
    end
  end
end
 
n = gets.to_i
n.times do
  command, $key = gets.split
  case command
  when "insert"
    insert
  when "find"
    if find($key.to_i)
      puts "yes"
    else
      puts "no"
    end
  when "delete"
    delete($key.to_i)
  else
    $root.inorder
    puts ""
    $root.preorder
    puts ""
  end
end

Measured memory_bytes: 57060
package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n, a, b int
	fmt.Fscanf(r, "%d %d %d\n", &n, &a, &b)

	if a == 0 {
		fmt.Fprintln(w, 0)
		return
	}

	div := n / (a + b)
	rem := n % (a + b)
	if rem >= a {
		fmt.Fprintln(w, div*a+a)
		return
	}
	fmt.Fprintln(w, div*a+rem)
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 998244353; // INFはそのまま使用

struct Combination{
    vector<ll> F, R;

    Combination(int N){ // 最大の値を代入
        fac(N);
    }

    ll power(ll m, ll n){
        if(n == 0) return 1;
        if(n % 2 == 1) return m * power(m, n - 1) % INF;
        ll tmp = power(m, n/2);
        return tmp * tmp % INF;
    }

    void fac(int N){
        F.assign(N + 1, 1);
        R.assign(N + 1, 1);
        for(ll i = 1; i <= N; i++){
            F[i] = F[i - 1] * i % INF;
            R[i] = power(F[i], INF - 2);
        }
    }

    ll com(ll m, ll n){
        if(m < 0 || n < 0 || m < n) return 0;
        ll tmp = F[m];
        tmp *= R[n];
        tmp %= INF;
        tmp *= R[m - n];
        tmp %= INF;
        return tmp;
    }
};



int main(){
    int N, M, K;
    cin >> N >> M >> K;
    
    Combination bc(200000);

    ll sum = 0, c = M;
    rep(i, N - K - 1){
        c *= M - 1;
        c %= INF;
    }

    for(ll k = K; k >= 0; k--){
        ll tmp = c * bc.com(N - 1, k);
        tmp %= INF;
        
        sum += tmp;
        sum %= INF;
        
        c *= M - 1;
        c %= INF;
    }

    cout << sum << endl;
}

Measured memory_bytes: 6432
N = int(input())
H = list(map(int, input().split()))
A = list(map(int, input().split()))


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret

st = SegmentTree([0]*2*(10**5), max, 0)

for _, a, i in sorted(zip(H, A, range(N))):
    st.update(i, st.query(0, i) + a)

print(st.query(0, N))


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

int cmp(void const *a,void const *b)
{
	return *(char*)a-*(char*)b;
}

int main()
{
	int i,j,x,c;
	char s[5]={0},t[5]={0};
	for(;scanf("%d\n",&x),x;)
	{
		if(!(x%1111))
		{
			puts("NA");
			continue;
		}
		for(c=0;x!=6174;c++)
		{
			for(i=0,j=1000;i<4;i++,x%=j,j/=10)
				s[i]=(x/j)+'0';
			qsort(s,4,sizeof(char),cmp);
			for(i=0;i<4;i++)
				t[3-i]=s[i];
			x=atoi(t)-atoi(s);
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
 
    #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 n; cin>>n;
    int a=1,b=1,c=1;
    for(int i=0;i<n;i++){
    	a=(a*10)%mod;
    	c=(c*9)%mod;
    	b=(b*8)%mod;
    }
    a=(a-b+mod)%mod;
    c=(c-b+mod)%mod;
    a=(a-2*c+2*mod)%mod;
    cout<<a<<endl;

}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "["; for (int i=0; i<(int)v.size(); i++) cout << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p>>=1;){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

string s;

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

    int l=0,r=s.length()-1,res=0;
    while (r>l){
        if (s[l]==s[r]){
            l++,r--;
        }
        else{
            res++;
            if (s[l]=='x') l++;
            else if (s[r]=='x') r--;
            else {
                cout << -1 << "\n";
                return 0;
            }
        }
    }

    cout << res << "\n";
	return 0;
}


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

#define ll long long int
#define ld long double

using namespace std;

int main(){

    ll n,m,i;
    cin >> n >> m;
    if(n<=m){
        for(i=0;i<m;i++){
            cout << n;
        }
    }
    else{
        for(i=0;i<n;i++){
            cout << m;
        }
    }

}


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

vector<int> X[1 << 17], Y[1 << 17];
int N, A[1 << 17], B[1 << 17], col[1 << 17], cnts;

void dfs(int pos) {
	if (col[pos] >= 1) return;
	col[pos] = cnts;
	for (int i = 0; i < X[pos].size(); i++) dfs(X[pos][i]);
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i]; B[i] = A[i];
		for (int j = 1; j * j <= A[i]; j++) {
			if (A[i] % j >= 1) continue;
			Y[j].push_back(A[i]);
			if (j * j != A[i]) Y[A[i] / j].push_back(A[i]);
		}
	}
	sort(B + 1, B + N + 1);

	for (int i = 2; i <= 100000; i++) {
		for (int j = 0; j < (int)Y[i].size() - 1; j++) {
			X[Y[i][j]].push_back(Y[i][j + 1]);
			X[Y[i][j + 1]].push_back(Y[i][j]);
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (col[i] >= 1) continue;
		cnts++; dfs(i);
	}

	for (int i = 1; i <= N; i++) {
		if (col[A[i]] != col[B[i]]) {
			cout << "0" << endl;
			return 0;
		}
	}
	cout << "1" << endl;
	return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> p(N);
    REP(i, N)
    {
        cin >> p[i];
        p[i]--;
    }

    vector<ll> a(N), b(N);
    REP(i, N)
    {
        a[i] = 1 + i * N;
        b[N - 1 - i] = a[i]; 
    }
    REP(i, N)
    {
        a[p[i]] += i;
        b[p[i]] += i;
    }

    REP(i, N)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    REP(i, N)
    {
        cout << b[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int h, w;
int dp[15][15], c[15][15];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> h >> w;
	FOR(i, 10) FOR(j, 10) {
		cin >> c[i][j];
		dp[i][j] = c[i][j];
	}
	FOR(k, 10) FOR(i, 10) FOR(j, 10) {
		dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
	}
	int ret = 0;
	FOR(i, h) FOR(j, w) {
		int a;
		cin >> a;
		if (a!=-1) {
			ret += dp[a][1];
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        cout << "vowel";
    else 
        cout << "consonant";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fly ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define ll long long
#define inf 100000000000
using namespace std;

int main(int argc, char const *argv[]) {
  fly;
  string s,t;
  cin >> s >> t;
  ll n = s.length();
  ll m = t.length();
  ll dp[n+2][m+2] = {0};
  for(int i = 0;i<=n;i++){
    for(int j = 0;j<=m;j++){
      if(i == 0 || j == 0){
        dp[i][j] = 0;
        continue;
      }
      if(s[i-1] == t[j-1])dp[i][j] = dp[i-1][j-1] + 1;
      dp[i][j] = max(dp[i][j], max(dp[i][j-1], dp[i-1][j]));
    }
  }

  int pos1 = n;
  int pos2 = m;
  string new_str = "";
  while(pos1 > 0 && pos2 >0){
    if(dp[pos1][pos2] == dp[pos1-1][pos2]){
      pos1--;
      continue;
    }
    if(dp[pos1][pos2] == dp[pos1][pos2-1]){
      pos2--;
      continue;
    }
    new_str = s[pos1-1] + new_str;
    pos1--;
    pos2--;
    continue;
  }
  cout << new_str << endl;

  return 0;
}


Measured memory_bytes: 74052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    int a;
    ll sum = 0;
    rep(0, i, N)
    {
        cin >> a;
        sum += a;
    }
    cout << sum - N << endl;
}


Measured memory_bytes: 256
import string

N = int(input())
al = string.ascii_lowercase

# if (N >= 1 and N <= 26):
#     print(al[N - 1])
#     exit()
# elif (N >= 27 and N <= 702):
#     n = N // 26
#     amari = N % 26
#     if (amari == 0 and n != 27):
#         print(al[n - 1] + al[25])
#         exit()
#     elif (amari == 0 and n == 27):
#         print(al[25] + al[25])
#         exit()
#     else:
#         print(al[n - 1] + al[amari - 1])
#         exit()
# elif (N >= 703):
s = ''
num = 26
while N > 26:
    amari = N % num
    N //= 26
    if (amari == 0):
        N -= 1
    if (amari == 0):
        s += al[25]
    else:
        s += al[amari - 1]
if (N == 0):
    s += al[25]
else:
    s += al[N - 1]
print(s[::-1])


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

int main(){
  int N,M;
  cin>>N>>M;
  int r[M];
  int l[M];
  int left=0;
  int right=100000;
  for (int i=0;i<M;i++){
    cin>>l[i]>>r[i];
    if(left<l[i]){
      left=l[i];
    }
    if(right>r[i]){
      right=r[i];
    }
  }
  if((right-left)<0){
    cout<<0<<endl;
    return 0;
  }
  
  cout<<right-left+1<<endl;
  return 0;
}

    
    

  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  ll sq=0,sum=0;
  int x=a[0],y=a[0];
  for(int i=0;i<n;i++)
  {
    if(x<a[i])x=a[i];
    if(y>a[i])y=a[i];
    sq=sq+(a[i]*a[i]);
    sum+=a[i];
  }
  ll ans;
  int start=y;
  for(int i=start;i<=x;i++)
  {
    ll cost=sq+(n*i*i)-(2*i*sum);
    if(i==start)ans=cost;
    else if(cost<ans)ans=cost;
  }
  cout<<ans<<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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    rep(i,N+1){
        cin >> A[i];
    }
    vector<ll> M(N+2);
    M[0] = 1;
    rep(i,N+1){
        if(A[i] > M[i]){
            cout << -1 << endl;
            return 0;
        }
        M[i+1] = M[i] - A[i];
        M[i+1] *= 2;
        if(M[i+1] > 1e18){
            REP(j,i,N){
                M[j+1] = 1e18;
            }
            break;
        }
    }
    //ll leaves = A[N];
    ll brus = 0;
    ll ans = 0;
    for(ll i=N;i>=0;i--){
        ans += A[i];
        brus = min(brus, M[i]-A[i]);
        ans += brus;
        brus = (A[i]+brus);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long LL;

int n,x,y,num;
struct Node
{
	int x,y,t;
}a[205];
set<int> s;
int ans=0;

bool cmp(Node a,Node b)
{
	return a.x<b.x;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%d%d",&x,&y);
		a[++num].x=x,a[num].y=y;a[num].t=0;
	}
	for (int i=1;i<=n;++i)
	{
		scanf("%d%d",&x,&y);
		a[++num].x=x,a[num].y=y;a[num].t=1;
	}
	sort(a+1,a+num+1,cmp);
	s.clear();
	for (int i=1;i<=num;++i)
	{
		if (a[i].t==1)
		{
			if (s.empty()) continue;
			if (*(s.begin())>a[i].y) continue;
			set<int>::iterator it=s.lower_bound(a[i].y);
			it--;
			s.erase(it);ans++;
		}
		else s.insert(a[i].y);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
//******************************************************************************
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}


signed main()
{
	int N;
	cin>>N;
	string s[N];
	rep(i,0,N){
		cin>>s[i];
	}
	int ans=0;
	int BA=0,B=0,A=0;
	rep(i,0,N){
		rep(j,0,s[i].size()-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B'){
				ans++;
			}
		}
		if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A')BA++;
		else if(s[i][0]=='B')B++;
		else if(s[i][s[i].size()-1]=='A')A++;
	}
	int t = 0;
	if(BA)t=BA-1;
	if(BA){
		if(A){
			A--;
			t++;
		}
		if(B){
			B--;
			t++;
		}
	}
	cout<<ans+t+min(A,B)<<endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int x[900][900],h,w,a,y[900],s;
queue<int>Q,R;
int main(){
	while(true){
		memset(x,0,sizeof(x));
		memset(y,0,3600);
		cin>>w>>h;
		if(!w){break;}
		for(int i=0;i<h*2-1;i++){
			if(i%2==1){
				for(int j=0;j<w;j++){
					cin>>a;
					if(!a){
						x[(i/2)*30+j][(i/2+1)*30+j]=1;
					}
				}
			}
			else{
				for(int j=0;j<w-1;j++){
					cin>>a;
					if(a==0){
						x[(i/2)*30+j][(i/2)*30+j+1]=1;
					}
				}
			}
		}
		Q.push(0);
		s=1;
		y[0]=1;
    	while(y[(h-1)*30+(w-1)]==0){
			while(!Q.empty()){
				a=Q.front();
				for(int j=0;j<900;j++){
					if((x[a][j]||x[j][a])&&!y[j]){
						y[j]=1;
						R.push(j);
					}
				}
				Q.pop();
			}
			while(!R.empty()){
				Q.push(R.front());
				R.pop();
			}
			s++;
			if(s>999){s=0;break;}
		}
		while(!Q.empty()){
			Q.pop();
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 4388
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,Q = IL()
s = S()
lr = [IL() for i in range(Q)]

dp = [0]*(len(s))

cnt = 0
for i in range(1,len(s)):
    if s[i] == "C":
        if s[i-1] == "A":
            cnt += 1
    dp[i] = cnt
for a,b in lr:
    print(dp[b-1]-dp[a-1])

Measured memory_bytes: 39608
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string s,t;
  cin >> s >> t;

  if(s==t.substr(0,s.size())){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 3628
n, x = map(int, input().split())
if 1 < x < 2 * n - 1:
    print("Yes")
    ans = [0] * (2 * n - 1)
    use = [0] * (2 * n - 1)
    if n == 2:
        ans = [i for i in range(1, 4)]
    else:
        if not x == 2 * n - 2:
            ans[n - 1], ans[n] = x - 1, x
            ans[n - 2], ans[n + 1] = x + 1, x + 2
            for i in range(4):
                use[x - 2 + i] = 1
        else:
            ans[n - 1], ans[n] = x + 1, x
            ans[n - 2], ans[n + 1] = x - 1, x - 2
            for i in range(4):
                use[x - 3 + i] = 1
        i = 0
        for j in range(2 * n - 1):
            if ans[j] == 0:
                while True:
                    if use[i] == 0:
                        use[i] = 1
                        break
                    i += 1
                ans[j] = i + 1
    for i in ans:
        print(i)
else:
    print("No")

Measured memory_bytes: 18644
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<complex>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef complex<double> P;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;
const double PI=acos(-1.0);

int n,l;
P rot(P center,double theta,P p){
	p-=center; p*=P(cos(theta),-sin(theta));
	return center+p;
}
	
int main()
{
	while(scanf("%d%d",&n,&l),n){
		P c(0,0),d(0,1);
		rep(i,n){
			int u,v,T; scanf("%d%d%d",&u,&v,&T);
			double t=T*PI/180;
			if(u==v){
				c+=P(u*t,0)*d;
			}
			else
			{
				P p=u==v?c:c+d*P(0,-1.0*l*(u+v)/(u-v));
				double theta=t*(u-v)/2.0/l;
				c=rot(p,theta,c);
				d*=P(cos(theta),-sin(theta));
			}
		}
		printf("%.6f\n%.6f\n",c.real(),c.imag());
	}
	return 0;
}

Measured memory_bytes: 0
import collections
N = int(input())
A = list(map(int,input().split()))
D = collections.Counter(A)
Q = int(input())
#print(D)
ans = sum(A)
for i in range(Q):
    B,C = map(int,input().split())
    #print(D[B],type(D[B]))
    ans += (C-B)*D[B]
    D[C] = D[B] + D[C]
    D[B] = 0
    #print(D)
    print(ans)

Measured memory_bytes: 24012
aa, bb, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
y = []
c = []
for i in range(m):
  x1, y1, c1 = list(map(int,input().split()))
  x.append(x1)
  y.append(y1)
  c.append(c1)

price = []
  
for i in range(m):
  price.append(a[x[i] - 1] + b[y[i] - 1] - c[i])
  
  
  
print(min(min(price), min(a) + min(b)))

Measured memory_bytes: 27876
def main():
    n = int(input())
    *a, = map(int, input().split())

    for x in a:
        if x % 2 == 1:
            continue

        if x % 3 == 0 or x % 5 == 0:
            continue

        print('DENIED')
        return

    print('APPROVED')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3064
import numpy as np

D = int(input())
c = list(map(int, input().split()))
c = np.array(c)
S = np.zeros([D, 26], dtype=int)
for i in range(D):
  S[i, :] = list(map(int, input().split()))

T = []
last = np.zeros(26)

for i in range(D):
  score = S[i, :] - (i-last)*np.array(c)
  argmax = score.argmax()
  t = argmax+1
  last[t-1] = i
  print(t)

Measured memory_bytes: 27320
import Data.List

solve :: Int -> Int -> Int -> Int -> String
solve x y xn y1 = if x < y1 && xn < y && xn < y1
                  then "No War"
                  else "War"

main :: IO ()
main = do
  [n, m, x, y] <- map read . words <$> getLine
  xs <- map read . words <$> getLine
  ys <- map read . words <$> getLine
  putStrLn $ solve x y (last $ sort xs) (head $ sort ys)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N; cin >> N;
  vector<ll> x(N), y(N); REP(i, N) cin >> x[i] >> y[i];
  ll max_v = -pow(10, 18); ll min_v = pow(10, 18); ll max_u = -pow(10, 18); ll min_u = pow(10, 18);
  REP(i, N) {
    ll v = x[i] - y[i];
    ll u = x[i] + y[i];
    if(max_v < v) max_v = v;
    if(min_v > v) min_v = v;
    if(max_u < u) max_u = u;
    if(min_u > u) min_u = u;
  }
  cout << max(max_v - min_v, max_u - min_u) << endl;
}

Measured memory_bytes: 6436
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!
ll F(ll a, ll b);
int main(void){
    ll N, s, i;
    scanf("%lld", &N);
    ll MIN = F(1, N);
    if(N%2==0) s=2;
    else s=3;
    for(i=s; i<=sqrt(N); i+=2){
        if(N%i==0){
            chmin(MIN, F(i, N/i));
        }
    }
    printf("%lld\n", MIN);
    return 0;
}
ll F(ll a, ll b){
    ll w, cnt=0;
    if(a>b) w=a;
    else w=b;
    while(w!=0){
        w /= 10;
        cnt++;
    }
    return cnt;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

bool find(vector<int>v, int key){
    bool flag = false;
    rep(i, v.size()){
        if(v[i] == key) flag = true;
    }
    return flag;
}

int main(){
    int x, n;   cin >> x >> n;
    vector<int>p(n);
    rep(i, n)   cin >> p[i];
    int ans = 100000;
    rep(i, 150){
        int l = x-i, r = x+i;
        if(!find(p, l)){
            ans = min(ans, l);
            break;
        }
        if(!find(p, r)){
            ans = min(ans, r);
            break;
        }
    }
    cout << ans << endl;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i=0; i<N; i++) {
		int x;
		cin >> x;
		ans += min(x, K - x);
	}
	cout << ans * 2 << endl;
}


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

#define pqint priority_queue<int>

int main() {
	vector<pqint> vec; int an, tn, fn1, fn2, en;
	cin >> an >> tn; vec.resize(an);
	for (int i = 0; i < tn; i++) {
		cin >> fn1;
		switch (fn1) {
		case 0: cin >> fn2 >> en; vec[fn2].push(en); break;
		case 1: cin >> fn2;
			if (vec[fn2].empty()) continue;
			else cout << vec[fn2].top() << endl;
			break;
		case 2: cin >> fn2;
			if (vec[fn2].empty()) continue;
			else vec[fn2].pop();
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 4000
num = list(input())
for i in range(4):
    num[i] = int(num[i])
res = [num[0]] * 8
for i in range(0,8):
    if i >> 2 & 1 == 1:
        res[i] += num[1]
    else:
        res[i] -= num[1]
    if i >> 1 & 1 == 1:
        res[i] += num[2]
    else:
        res[i] -= num[2]
    if i & 1 == 1:
        res[i] += num[3]
    else:
        res[i] -= num[3]
for i in range(0,8):
    if res[i] == 7:
        op1 = "+" if i >> 2 & 1 == 1 else "-"
        op2 = "+" if i >> 1 & 1 == 1 else "-"
        op3 = "+" if i >> 0 & 1 == 1 else "-"
        print(str(num[0])+op1+str(num[1])+op2+str(num[2])+op3+str(num[3])+"=7")
        break

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n,m;
  int x[55]={0};
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    x[a]++;x[b]++;
  }
  for(int i=1;i<=n;i++){
    cout<<x[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import Data.Bits
import Data.Char

solve abcd b
    | x == 7 = y ++ "=7"
    | otherwise = solve abcd (b+1)
    where
        (x,y) = calc abcd b (show $ head abcd)
        calc :: [Int] -> Int -> String -> (Int, String)
        calc [x] b acc = (x,acc)
        calc (x:y:xs) b acc
            | b .&. 1 == 1 = calc ((x+y):xs) q (acc ++ "+" ++ show y)
            | otherwise = calc ((x-y):xs) q (acc ++ "-" ++ show y)
            where
                q = b `quot` 2

main = do
    abcd <- map digitToInt <$> getLine
    putStrLn $ solve abcd 0 

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define L long long
using namespace std;
const int q=1000000007;
int n,m,x[100010],t,f[100010],p;
inline int power(int a,int b)
{
	if(!b)
	  return 1;
	int c=power(a,b>>1);
	c=(L)c*c%q;
	if(b&1)
	  c=(L)c*a%q;
	return c;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i*i<=n;i++)
	  if(n%i==0)
	    {
		 x[++t]=i;
		 if(n/i!=i)
		   x[++t]=n/i;
		}
	sort(x+1,x+t+1);
	for(i=1;i<=t;i++)
	  {
	   f[i]=power(m,(x[i]+1)/2);
	   for(j=1;j<i;j++)
	     if(x[i]%x[j]==0)
	       f[i]=(f[i]-f[j])%q;
	   p=(p+(L)f[i]*((x[i]&1)?x[i]:(x[i]/2)))%q;
	  }
	p=(p+q)%q;
	printf("%d\n",p);
	return 0;
}


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

int search(vector<int> data,int t,bool R = true)
{
    int left = -1;
    int right = (int)data.size();
    
    if(R)
    {
        while(right - left > 1)
        {
            int mid = (right + left)/2;
            
            if(data[mid] > t) right = mid;
            else left = mid;
        }
        return right;
    }
    else
    {
        while(right - left > 1)
        {
            int mid = (right + left)/2;
            
            if(data[mid] >= t) right = mid;
            else left = mid;
        }
        return left;
    }
    
   
    
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N),b(N),c(N);
    
    for(int i=0;i<N;i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<N;i++)
    {
        cin >> b[i];
    }
    for(int i=0;i<N;i++)
    {
        cin >> c[i];
    }
    
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    long long ans = 0;
    
    for(int i=0;i<N;i++)
    {
        ans += (lower_bound(a.begin(),a.end(),b[i]) - a.begin()) * (N- (upper_bound(c.begin(),c.end(),b[i]) - c.begin()));
    }
    
    cout<<ans<<endl;
    return 0;
    
    
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        System.out.println(a >=1000 ? "ABD" : "ABC");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<30;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  string S, T; cin >> S >> T;

  vi start(26,-1), goal(26,-1);
  rep(i,S.size()) {
    int a = S[i]-'a';
    int b = T[i]-'a';
    if (start[a]!=-1 || goal[b]!=-1) {
      if (start[a]!=b || goal[b]!=a) {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      start[a] = b;
      goal[b] = a;
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
n,k = map(int,input().split()) # k>p の時 最大値p+1
p = n-k
mod = 10**9 + 7
def kai(n):
    p = 1
    for i in range(1,n+1):
        p = p*i % mod
    return p
def com(n,k):
    s = 0
    if n < k :
        return 0
    else:
        s = kai(n)*(pow(kai(k),mod-2,mod))*(pow(kai(n-k),mod-2,mod))
        return s%mod
for i in range(1,k+1):
    print(com(p+1,i)*com(k-1,i-1)%mod)

Measured memory_bytes: 3316