akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
# define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/
i64 c(i64 n) {
  return n * (n - 1) / 2;
}
int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, m; cin >> n >> m;
  cout << c(n) + c(m) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

ll dp[1000][1000];
bool used[1000][1000];
int main() {
    init();
    ll H, W;
    cin >> H >> W;
    vc<string> S(H);
    rep(i, H) cin >> S[i];

    dp[0][0] = 1;
    queue<pair<ll,ll>> q;
    q.emplace(0, 0);
    while(!q.empty()){
        ll h, w;
        tie(h, w) = q.front(), q.pop();
        if (used[h][w]) continue;
        used[h][w] = true;
        
        if (w + 1 < W and S[h][w + 1] == '.'){
            (dp[h][w + 1] += dp[h][w]) %= MOD;
            q.emplace(h, w + 1);
        }
        if (h + 1 < H and S[h + 1][w] == '.'){
            (dp[h + 1][w] += dp[h][w]) %= MOD;
            q.emplace(h + 1, w);
        }    
    }

    cout << dp[H-1][W-1] << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    string s;
    cin >> s;

    vector<int> w(n+1);
    vector<int> e(n+1);
    for(int in=1;in<=n;in++) {
        if(s.at(in-1)=='W') { 
            w.at(in) += w.at(in-1) + 1;
            e.at(in) = e.at(in-1);
        }
        else { 
            e.at(in) += e.at(in-1) + 1;
            w.at(in) = w.at(in-1);
        }
    }

    int ans=n+10;
    for(int in=1;in<=n;in++) {
        if(in==n) ans = min(ans, w.at(in-1));
        else ans = min(ans, w.at(in-1)+e.at(n)-e.at(in));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N, M, A[10]; 
	cin >> N >> M; 
	int C[10] = {0,2,5,5,4,5,6,3,7,6}; 
	for(int i = 0; i < M; i++){
		cin >> A[i]; 
	}
	sort(A, A+M, greater<int>()); 
	int dp[10010] = {}; // 最大の桁数
	int INF = -1145141919; 
	fill(dp, dp+N+1, INF); dp[0] = 0; 
	for(int i = 2; i <= N; i++){
		for(int j = 0; j < M; j++){
			if(i - C[A[j]] >= 0){
				dp[i] = max(dp[i], dp[i - C[A[j]]] + 1); 
			}
		}
	}
	int L = N; 
	vector<int> ans = {}; 
	for(int i = 0; i < M; i++){
		while(L > 0 && L - C[A[i]] >= 0 && dp[L] == dp[L - C[A[i]]] + 1){
			ans.push_back(A[i]); L -= C[A[i]]; 
		}
	}
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i]; 
	}
	cout << endl; 
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

struct UnionFind{
    vector<ll> parent;// 各元の親を表す配列(-1で初期化)
    vector<ll> rank; // 素集合の深さを表す配列
    vector<ll> siz; // 素集合のサイズを表す配列
    UnionFind(ll n){
        parent.resize(n,-1);
        rank.resize(n,1);
        siz.resize(n,1);
    }

    // xの根を返す
    ll find(ll x){
        if(parent[x]==-1) return x;
        return parent[x] = find(parent[x]); 
    }

    //yにxを結合する(yがxの根となる)
    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        if(rank[x]>rank[y]) swap(x,y);
        if(rank[x]==rank[y]) rank[y]++;
        parent[x] = y;
        siz[y]+=siz[x];
    }

    // xとyの根が等しいかを返す
    bool same(ll x, ll y) {return find(x)==find(y);}

    // xが属する素集合のサイズを返す
    ll size(ll x){return siz[find(x)];}
};

void solve() {
    ll N,M;
    cin >> N >> M;
    UnionFind u = UnionFind(N);
    ll a,b;
    rep(i,M){
        cin >> a >> b;
        a--;b--;
        if(a>b) swap(a,b);
        u.unite(a,b);
    }
    ll ans = 1;
    rep(i,N){
        ans = max(ans, u.size(i));
    }
    print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 7928
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Linq;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        long sum = 0;
        foreach (var i in a)
            sum += i - 1;
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13340
# [input]
# n = int(input())
# (string) s = input()
# a, b, c = map(int, input().split())
# h = list(map(int, input().split()))


a, b, t = map(int, input().split())
ans = 0
for i in range(t + 1):
    if i % a == 0 and i != 0:
        ans = ans + b
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,t,m=0,k=1;
    cin>>n;
    vector<int>v;
    vector<int>l(n,1);
    for(int i=0;i<n;i++){
        cin>>t;
        v.push_back(t);
    }
    for(int i=1;i<n;i++){
        if(v[i-1]!=v[i]){
            l[i]=l[i-1]+1;
        }
    }
    for(int i=n-2;i>=0;i--){
        m=max(m,k+l[i]+l[i-l[i]]);
        k=v[i]==v[i+1]?1:k+1;
    }
    cout<<m<<endl;
}

Measured memory_bytes: 2064
//#pragma GCC optimize("O2")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 2e5 + 555;
using ld = long double;
ll n, k, a[54];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> k;
	n = max(2ll, min(50ll, k));
	for(int i = 0; i < n; i++) {
		a[i]+=n+k/n-1;
	}
	k%=n;
	for(int i = 0; i < k; i++) {
		int j = 0;
		for(int k = 0; k < n; k++) {
			if(a[k]<a[j]) j = k;
		}
		for(int k = 0; k < n; k++) {
			if(k==j) a[k] += n;
			else a[k]--;
		}
	}
	cout << n << "\n";
	for(int i = 0; i < n; i++) cout << a[i] << " ";
}
/*

*/


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a==1) a=9999;
  if(b==1) b=9999;
  if(a>b)cout << "Alice";
  if(a<b)cout << "Bob";
  if(a==b)cout << "Draw";
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)

using ll = int64_t;
using ld = long double;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr ll inf = 2e18;
constexpr int M = 1e9 + 7;


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

	int n, K; cin >> n >> K;
	int a[n]; rep(i, 0, n) cin >> a[i];
	bool dp[K + 1] = {0};
	rep(k, 1, K + 1) {
		dp[k] = 0;
		rep(i, 0, n) {
			if (a[i] > k) break;
			if (!dp[k - a[i]]) {
				dp[k] = true;
				break;
			}
		}
	}
	cout << (dp[K] ? "First" : "Second");
}

Measured memory_bytes: 384
/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <cmath>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>
#define dump(x) cerr<< #x << " = " << x <<endl

using namespace std;
const int INF=1<<25;
void io(){ cin.tie(0);ios::sync_with_stdio(false);}
/*printf("%.9Lf\n",cf);*/
const int MOD=1000000007;

struct pre{
	int f,a,t,x,y;
};

int main(){
	io();
	int n;
	cin>>n;
	pair <double,double> pass[2]={make_pair(-1,-1),make_pair(-1,-1)};
	pre pre_log;
	pre_log.t=-1;
	for(int i=0;i<n;i++){
		int f,a,t,x,y;
		cin>>f>>a>>t>>x>>y;
		if(t==pre_log.t && a!=pre_log.a){
			double dist=sqrt(1.0*(x-pre_log.x)*(x-pre_log.x)+(y-pre_log.y)*(y-pre_log.y));
			double tm=(f-pre_log.f)*1.0/60;
			if(dist>pass[t].first){
				pass[t].first=dist;
				pass[t].second=tm;
			}else if(dist==pass[t].first){
				if(pass[t].second!=-1){
					pass[t].second=min(pass[t].second,tm);
				}else{
					pass[t].second=tm;
				}
			}
		}
		pre_log.f=f;
		pre_log.a=a;
		pre_log.t=t;
		pre_log.x=x;
		pre_log.y=y;
	}
	cout<<setprecision(10)<<pass[0].first<<' '<<pass[0].second<<endl;
	cout<<setprecision(10)<<pass[1].first<<' '<<pass[1].second<<endl;


	return 0;
}

Measured memory_bytes: 1268
N, K = [int(i) for i in input().split()]
cnt = 0
sunuke_dict = {}
for i in range(1, N+1):
    sunuke_dict[i] = 0
    
while cnt < K:
    cnt += 1
    d = int(input())
    sunuke_list = [int(i) for i in input().split()]
    for sunuke in sunuke_list:
        sunuke_dict[sunuke] = 1

result = [key for key, value in sunuke_dict.items() if value == 0]
print(len(result))

Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n,a[200000],g;
bool use=false;
int gcd(int x,int y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    g=a[0];
    rep(i,n)g=gcd(g,a[i]);
    rep(i,n){
        a[i]/=g;
    }
    if(n==2)cout<<a[1]*g<<endl;
    else{
        int b=gcd(a[0],gcd(a[1],a[2]));
        int c[3];
        c[0]=gcd(a[0],a[1]);c[1]=gcd(a[1],a[2]);c[2]=gcd(a[2],a[0]);
        sort(c,c+3);
        for(int i=3;i<n;i++){
            if(gcd(b,a[i])==1&&use==false){
                use=true;
            }
            else b=gcd(b,a[i]);
            c[0]=gcd(c[0],a[i]);
            c[1]=gcd(c[1],a[i]);
            c[2]=gcd(c[2],a[i]);
        }
        sort(c,c+3);
        int ans=max(b,c[2]);
        cout<<ans*g<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
    
int main(){
int a,b,c,k;
cin>>a>>b>>c>>k;

int sum=0;

if (k<a+1)
{
  sum=k;
}
else if ((a<k)&&(k<(a+b+1)))
{
  sum=a;
}
else if ((a+b)<k)
{
  sum=a-(k-(a+b));
}

cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string str;
  int sum;
  
  while (1) {
    cin >> str;
    cin.ignore();
    if (str == "0") break;
    sum = 0;
    for (int i = 0; i < str.size(); i++) {
      sum += str[i] - 0x30;
    }
    cout << sum << endl;
  }
}



Measured memory_bytes: 3224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            for (int i = 0; i < q; i++) {
                int v = in.nextInt() - 1;
                int w = in.nextInt() - 1;

                if (n == 1) {
                    out.println(Math.min(v + 1, w + 1));
                    continue;
                }

                Set<Integer> set = new TreeSet<>();
                while (v > 0) {
                    set.add(v);
                    v = (v - 1) / n;
                }
                set.add(0);

                while (true) {
                    if (set.contains(w)) {
                        out.println(w + 1);
                        break;
                    }
                    if (w == 0) throw new RuntimeException();
                    w = (w - 1) / n;
                }
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 93020
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        bool compare(pair<int,int> a,pair<int,int> b){
            if(a.first==b.first)
                return a.second<b.second;
            return a.first<b.first;
        }

        signed main() {
 
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // int n,m,q;
        // cin>>n>>m>>q;

        // vector<pair<int,pair<int,pair<int,int>>>> v(q);

        // for(int i=0;i<q;i++){
        //     cin>>v[i].sc.sc.sc>>v[i].sc.sc.ft>>v[i].sc.ft>>v[i].ft;
        // }

        // sort(v.begin(),v.end());
        
        // vector<int> arr(n+1,1);

        // for(int i=q-1;i>=0;i--){

        //     int bi=v[i].sc.sc.ft, ai=v[i].sc.sc.sc;
        //     int ci=v[i].sc.ft;



        // }

        int a,b,n;
        cin>>a>>b>>n;
        int val = min(n,b-1);
        int ans = a*val/b;

        cout<<ans;


        return 0;
    }

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
signed main(){
	int n,k;
	cin>>n>>k;
	int now=1;
	rep(i,n)now=min(now+k,now*2);
	cout<<now<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX_L 8
#define NIL -1
#define FREE 0
#define NOT_FREE 1
int row[MAX_L];
int column[MAX_L];
int dpos[2*MAX_L-1];
int dneg[2*MAX_L-1];
int wholeGraph[MAX_L][MAX_L];
void printBoard()
{
    for(int i=0;i<MAX_L;i++)
    {
        for(int j=0;j<MAX_L;j++)
        {
            if(wholeGraph[i][j]==NOT_FREE && row[i]!=j)return;
        }
    }
    for(int i=0;i<MAX_L;i++)
    {
        for(int j=0;j<MAX_L;j++)
        {
            printf("%c", (row[i]==j) ? 'Q' : '.');
        }
        printf("\n");
    }
}
void putQueen(int i)
{
    if(i==MAX_L)
    {
        printBoard();
        return;
    }
    for(int j = 0;j<MAX_L;j++)
    {
        if(column[j]==NOT_FREE||dpos[i+j]==NOT_FREE||dneg[i-j+MAX_L-1]==NOT_FREE)
            continue;
        row[i]=j;
        column[j]=dpos[i+j]=dneg[i-j+MAX_L-1] = NOT_FREE;
        putQueen(i+1);
        column[j] = dpos[i+j] = dneg[i-j+MAX_L-1] = FREE;
    }
}
int main() {
    for(int i =0;i<MAX_L;i++)
    {
        column[i]=FREE;
        for(int j = 0;j<MAX_L;j++){wholeGraph[i][j]=FREE;}
    }
    for(int i = 0;i<2*MAX_L;i++)
    {
        dpos[i]=FREE;
        dneg[i]=FREE;
    }
    int n;
    int ro, co;
    scanf("%d", &n);
    for(int i = 0;i<n;i++){
        scanf("%d %d", &ro, &co);
        wholeGraph[ro][co] = NOT_FREE;
    }
    putQueen(0);
    return 0;
}



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

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  if(n % max(h,w) == 0){
    cout << n/max(h,w) << endl;
  }
  else cout << n/max(h,w) + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#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>;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

ll nums[3];
char answer[100002];
string S[100002];

ll alphabet2num(char alphabet){
    if (alphabet=='A') return 0;
    if (alphabet=='B') return 1;
    if (alphabet=='C') return 2;
    else return -1;
}

char num2alphabet(ll num){
    if (num==0) return 'A';
    if (num==1) return 'B';
    if (num==2) return 'C';
    else return 'X';
}


bool isCharIncludedInStr(char c, string s){
    for(int i=0; i<s.size(); i++){
        if (c==s[i]) return true;
    }
    return false;
}


int main(){
    ll N, l, r;
    string s;
    cin >> N >> nums[0] >> nums[1] >> nums[2];
    for(int i=0; i<N; i++){
        cin >> S[i];
    }


    ll sum = nums[0] + nums[1] + nums[2];
    if (sum == 0){
        cout << "No" << endl;
        return 0;
    }
    else if (sum==1){
        for(ll i=0; i<N; i++){
            s = S[i];
            l = alphabet2num(s[0]);
            r = alphabet2num(s[1]);
            if (max(nums[l], nums[r])<=0){
                cout << "No"<< endl;
                return 0;
            }
            if (nums[l] < nums[r]){
                answer[i] = num2alphabet(l);
                nums[l] ++;
                nums[r] --;
            }else{
                answer[i] = num2alphabet(r);
                nums[l] --;
                nums[r] ++;
            }
        }
        cout << "Yes" << endl;
        for(ll i=0; i<N; i++){
            cout << answer[i] << endl;
        }
        return 0;
    }else{
        for(ll i=0; i<N; i++){
            s = S[i];
            l = alphabet2num(s[0]);
            r = alphabet2num(s[1]);

            if (nums[l]==0 && nums[r]==0){
                cout << "No" << endl;
                return 0;
            }
            if (nums[l]==0 && nums[r]>0){
                answer[i] = num2alphabet(l);
                nums[l] ++;
                nums[r] --;
            }else if (nums[l]>0 && nums[r]==0){
                answer[i] = num2alphabet(r);
                nums[l] --;
                nums[r] ++;
            }else if (sum==2 && nums[l]==1 && nums[r]==1 && i!=N-1 && S[i]!=S[i+1]){
                if (isCharIncludedInStr(s[1], S[i+1])){
                    answer[i] = num2alphabet(r);
                    nums[l] --;
                    nums[r] ++;
                }else{
                    answer[i] = num2alphabet(l);
                    nums[l] ++;
                    nums[r] --;
                }
            }else{
                if (nums[l] > nums[r]){
                    answer[i] = num2alphabet(r);
                    nums[l] --;
                    nums[r] ++;
                }else{
                    answer[i] = num2alphabet(l);
                    nums[l] ++;
                    nums[r] --;
                }
            }
        }

        cout << "Yes" << endl;
        for(ll i=0; i<N; i++){
            cout << answer[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6820
N = int(input())
T = list(map(int, input().rstrip().split()))

M = int(input())
P, X = [], []
for i in range(M):
    p, x = map(int, input().rstrip().split())
    P.append(p)
    X.append(x)

A = sum(T)

for i in range(M):
    p = P[i]
    x = X[i]
    print(A - T[p-1] + x)


Measured memory_bytes: 3064
#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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int cntA = 0;
  int cntB = 0;
  vector<int> ans(n);
  rep(i,n) {
    if (s[i] == 'c') ans[i] = 0;
    else if (s[i] == 'a') {
      if (cntA + cntB < a + b) {
        cntA++;
        ans[i] = 1;
      } else ans[i] = 0;
    } else {
      if ((cntA + cntB < a + b) && cntB + 1 <= b) {
        cntB++;
        ans[i] = 1;
      } else ans[i] = false;
    }
  }
  rep(i,n) cout << (ans[i]? "Yes": "No") << endl;
}

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

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

using namespace std;
int MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i = 0 ; i < n ; i++ ){
    cin >> x[i];
  }
  int minv = 1e9;
  for(int i = 1 ; i <= 100 ; i++ ){
    int sum1 = 0;
    for(int j = 0 ; j < n ; j++ ){
      sum1 += ( x[j] - i ) * ( x[j] - i);
    }
    minv = min(minv,sum1);
  }
  cout << minv << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		long n = Long.parseLong(scan.next());
		long m = Long.parseLong(scan.next());

		long ans = 0;
		ans += Math.min(n,m/2);
		n -=ans;
		m -=ans*2;
		if (m > 0){
			ans+=m/4;
		}
		System.out.print(ans);

	}
}
//end


Measured memory_bytes: 23636
n,m,x=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[0]*n
for i in range(n):
  c[i]=a[i].pop(0)

ans=sum(c)+1
for i in range(2**n):
  rikaido=[0]*m
  money=0
  for j in range(n):
    if ((i>>j)&1):
      money+=c[j]
      for k in range(m):
        rikaido[k]+=a[j][k]
  for k in range(m):
    if rikaido[k]<x:
      break
  else:
    if money<ans:
      ans=money

if ans>sum(c):
  print('-1')
else:
  print(ans)

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

int main() {
  int N,K;
  cin >> N >> K;
  int x[50],y[50];
  int sort_x[50],sort_y[50];
  for (int i=0; i<N; i++) {
    scanf("%d %d",x+i,y+i);
    sort_x[i]=x[i];
    sort_y[i]=y[i];
  }
  sort(sort_x,sort_x+N);
  sort(sort_y,sort_y+N);

  ll ans=4*1e18;
  for (int i=0; i<N-1; i++) {
    for (int j=i+1; j<N; j++) {
      for (int k=0; k<N-1; k++) {
	for (int l=k+1; l<N; l++) {
	  int cnt=0;
	  for (int m=0; m<N; m++) {
	    if (x[m]>=sort_x[i]
		&&x[m]<=sort_x[j]
		&&y[m]>=sort_y[k]
		&&y[m]<=sort_y[l])
	      cnt++;
	  }
	  if (cnt<K) continue;
	  ll s=(ll)(sort_x[j]-sort_x[i])*(sort_y[l]-sort_y[k]);
	  if (s<ans)
	    ans=s;
	}
      }
    }
  }

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<int> l;
    set<int> r;
    int m = 0;
    for (int x = 0; x < n - 1; x++) {
        l.insert(s[x]);
        for (int i = x + 1; i < n; i++) {
            r.insert(s[i]);
        }
        int cur = 0;
        for (int a : l) {
            if (r.count(a)) cur++;
            m = max(m, cur);
        }
        r.clear();
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <unistd.h>

char ibuf[(11<<18)+5];
char *ibufe = ibuf-1;

extern inline void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[40];
char *bufe = buf;

void write_uintln(int x){
  int i;
  static char tmp[13];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

extern inline void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


#define MAX(x, y) ((x) > (y) ? (x) : (y))

int n;
int A[1<<18];
int B[1<<18];

void zeta(int n){
  int i, j;
  int m = 1 << n;
  for(i=1;i<m;i<<=1){
    for(j=0;j<m;j++){
      if(j&i){
        if(A[j] >= A[j^i]){
          if(A[j^i] > B[j]) B[j] = A[j^i];
        }
        else {
          B[j] = MAX(A[j], B[j^i]);
          A[j] = A[j^i];
        }
      }
    }
  }
}


int main(){
  int i, max;
  readall();
  n = read_uint();
  for(i=0;i<(1<<n);i++){
    A[i] = read_uint();
  }
  zeta(n);
  max = 0;
  for(i=1;i<(1<<n);i++){
    max = MAX(max, A[i]+B[i]);
    write_uintln(max);
  }
  writeall();
  return 0;
}


Measured memory_bytes: 7808
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main{
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;
		//PrintStream out = new PrintStream("src/output.txt");

		//System.setOut(out);

		sc = new Scanner(in);

		String S = sc.next();
		StringBuilder sb = new StringBuilder();
		sb.append(S);
		int answer = 0;


		for(int i = 0; i < Math.ceil(sb.length() / 2.0); i++){
			//System.out.println(i + "\t" + sb.charAt(i) + "\t" + sb.charAt(sb.length() - 1 - i));
			if(sb.charAt(i) != sb.charAt(sb.length() - 1 - i)){
				if(sb.charAt(i) == 'x'){
					sb.insert(sb.length() - i, 'x');
					i--;
					answer++;
				}else if(sb.charAt(sb.length() - 1 - i) == 'x'){
					sb.insert(i, 'x');
					i--;
					answer++;
				}else{
					answer = -1;
					break;
				}
			}

			if(i+1 == Math.ceil(sb.length() / 2.0)){
				if(sb.charAt(i) != sb.charAt(sb.length() - 1 - i)){
					answer = -1;
				}
			}

			//System.out.println(sb);
		}

		System.out.println(answer);

		//out.close();
	}
}

Measured memory_bytes: 27204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, p1, p2, x;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            if (a * n < b)
                x = a * n;
            else 
                x = b;


            Console.WriteLine(x);

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long

char solve(char x, ll n)
{
    while(n--)
    {
        x++;
        if(x>'Z') x='A';
    }
    return x;
}

int main()
{
    string s;
    ll n, i;
    cin>>n;
    cin.ignore();
    cin>>s;
    for(i=0; i<s.size(); i++) s[i]=solve(s[i], n);

    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    int res = X%100;
    int num = X/100;

    if (res<=num*5) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }


}





Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N,X;
int m[1003];
int main(){
    cin>>N>>X;
    for(int i=0;i<N;++i)cin>>m[i];

    int sum,Min;
    sum=0;
    Min=10000000;
        for(int i=0;i<N;++i){
            sum+=m[i];
                if(Min>m[i])Min=m[i];
        }
    cout<<N+(X-sum)/Min;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e5+7;
const int mod =1e9+7;
ll pz[M],pf[M];
ll z[M],f[M];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
  	int n,k;cin>>n>>k;
  	int nm=0;//0的数量 
	int zm=0,fm=0;
  	for(int i=1;i<=n;i++)
  	{
  		int x;cin>>x;
  		if(x>0)z[++zm]=x;
  		else if(x<0)f[++fm]=-x;
  		else nm++;
	}
  	sort(z+1,z+1+zm);
  	sort(f+1,f+1+fm);
  	if(n-k<nm)
  	{
  		cout<<0<<endl;
  		return 0;
	}
	ll ans=1;
	if(zm+fm==k)
	{
		for(int i=1;i<=zm;i++)ans=ans*z[i]%mod;
		for(int i=1;i<=fm;i++)ans=ans*(-f[i])%mod;
		if(fm&1 && nm)ans=0;
		ans=(ans+mod)%mod;
		cout<<ans<<endl;
		return 0;
	}
	if(zm==0 && k&1)
	{
		for(int i=1;i<=k;i++)ans=ans*(-f[i])%mod;
		if(nm)ans=0;
		ans=(ans+mod)%mod;
		cout<<ans<<endl;
		return 0;
	}
	int q=zm,w=fm;
	int nw=0;
	while(nw<=k)
	{
		if(k-nw>=2)
		{
			if((q>=2 && z[q]*z[q-1]>f[w]*f[w-1])||w<2)
			{
				ans=ans*z[q]%mod;
				ans=ans*z[q-1]%mod;
				q-=2;
			}
			else
			{
				ans=ans*f[w]%mod;
				ans=ans*f[w-1]%mod;
				w-=2;
			}
			nw+=2;
		}
		else if(k-nw==1)
		{
			ans=ans*z[q]%mod,q--;
			nw++;
		}
		else break;
	}
	cout<< ans<<endl;
	return 0;
}

Measured memory_bytes: 5204
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define ff first
#define ss second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define frb(i,j, n) for (auto (i) = (j); (i) >= (n); (i)--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define ra(a) for(int &x : (a)) cin >> (x)
#define pa(a) for(int &x : (a)) cout << (x) << " ";cout << "\n"
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>
#define debug() if(0)

#define TMP template<typename
/*----------fast input-------------*/
#ifdef LOCAL 
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
    
    ~debug() { cerr << endl; }
    template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return * this; }
    template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return * this << range(begin(i), end(i)); }
    template < class c, class b > debug & operator <<(pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }};
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cerr << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
void in(int &x){
    cin  >> x;
}
#else
inline void in(int &x)
    {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s , t;
  cin >> s >> t;
  int c = 0;
  fri(i,0,3){
      if(s[i] == t[i])
        c++;
  }
  cout << c;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

VP C;
vector<double> R;
vector<VP> PG;
int N,M;

// rotation a->b [-pi,+pi]
double angle(Point a,Point b){
    double t = arg(b)-arg(a);
    while(t>+M_PI) t-=2*M_PI;
    while(t<-M_PI) t+=2*M_PI;
    return t;
}

bool inPolygon(Point p,VP& ps){
    int n = ps.size();
    double sumAngle=0;
    rep(i,n){
        sumAngle += angle(ps[i]-p, ps[(i+1)%n]-p);
    }
    return (abs(sumAngle) > 0.1);
}

bool notCross(Point p,Point q){
    bool inAnyCircle = false;
    rep(i,N){
        inAnyCircle |= abs(C[i]-p)<R[i];
        if((abs(C[i]-p)<R[i]) != (abs(C[i]-q)<R[i])) return false;
    }
    if(inAnyCircle) return true;
    
    rep(i,PG.size()){
        if(inPolygon(p,PG[i]) != inPolygon(q,PG[i])) return false;
    }
    return true;
}

int main(void){
    while(cin>>N>>M, N|M){
        C = VP(N);
        R = vector<double>(N);
        rep(i,N){
            double x,y;
            cin>>x>>y>>R[i];
            C[i] = {x,y};
        }

        vector<map<double,int>> G(N);
        rep(i,N)rep(j,N)if(i!=j){
            double d = abs(C[i]-C[j]);
            if(R[i]+R[j]>=d && abs(R[i]-R[j])<d){
                G[i][arg(C[j]-C[i])] = j;
                G[j][arg(C[i]-C[j])] = i;
            }
        }
        
        PG.clear();
        rep(start,N){
            while(G[start].size()){
                int pre = start;
                int cur = (G[start].begin())->second;
                G[start].erase(G[start].begin());
                VP ps = {C[pre]};
                while(cur!=start){
                    ps.push_back(C[cur]);
                    auto itr = G[cur].upper_bound(arg(C[pre]-C[cur]));
                    if(itr==G[cur].end()) itr = G[cur].begin();
                    pre = cur;
                    cur = itr->second;
                    G[pre].erase(itr);
                }
                PG.push_back(ps);
            }
        }

        rep(i,M){
            double px,py,qx,qy;
            cin>>px>>py>>qx>>qy;
            cout<<(notCross(Point(px,py),Point(qx,qy)) ? "YES" : "NO");
            cout<<(i<M-1 ? " " : "\n");
        }
    }

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,q,l,r,i;
    cin>>n>>q;
    string s;
    cin>>s;
    int p1[n+2]={0},p2[n+2]={0};
    for (i=0;i<n-1;i++)
    {
        if (s[i]=='A' && s[i+1]=='C')
        {
            p1[i+2]++;
            p2[i+2]++;
        }
    }
    for (i=1;i<=n;i++)
        p1[i]+=p1[i-1];
    while (q--)
    {
        cin>>l>>r;
        if (p2[l]==1)
            cout<<p1[r]-p1[l-1]-1<<endl;
        else
            cout<<p1[r]-p1[l-1]<<endl;
    }
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

const ll mod = 1e9+7;

ll Pow(ll a, ll b)
{
	ll x = 1;
	for (; b > 0; b >>= 1)
	{
		if (b&1) x = x * a % mod;
		a = a * a % mod;
	}
	return x;
}

ll fac[100005], ifac[100005];

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<ll> a(n);
	for (auto &i : a) cin >> i;

	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		fac[i] = fac[i-1] * i % mod;
		ifac[i] = Pow(fac[i], mod-2);
	}

	ll ans = 0, l = 0;
	for (int j = 2; j <= n; ++j)
	{
		ll cur = 0;
//		for (int i = 1; i < j; ++i)
//			cur = (cur + fac[j-i-1] * fac[n-1] % mod * ifac[j-i]) % mod;
		l = (l + fac[n-1] * Pow(j-1, mod-2)) % mod;
		cur = (cur + l) % mod;

		//cur = cur * fac[n-1] % mod;
		ans = (ans + (a[j-1]-a[j-2]) * cur) % mod;
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 2560
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <=(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    string s,alpha="abcdefghijklmnopqrstuvwxyz";
    cin>>s;
    vector<bool> a(alpha.size(),1);
    rep(i,s.size()){
      rep(j ,alpha.size()){
          if(s[i]==alpha[j])a[j]=0;
      }
    }
    rep(i,alpha.size()){
        if(a[i]){
         cout<<alpha[i]<<endl;
         exit(0);
        }
    }
    cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n; IN(n);
    vector<int> x(n)$in(x, n);
    sort(ALL(x));
    int first, last;
    first = x[0]; last = x.back();
    ll ans = INF;
    rep(i, first, last+1){
        ll t = 0;
        rep(j, 0, n) t += pow(x[j]-i, 2);
        chmin(ans, t);
    }
    cout << ans << el;
    return 0;
}


Measured memory_bytes: 3224
//Date : Sun Feb 25 21:33:21 2018
//Author : Rishabh Paul
 
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(int i=0;i<n;i++)
#define rep(i ,a ,b)	for(int i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define LEFT(i)	2*i + 1
#define RIGHT(i)	2*i + 2
#define EPS 0.00000000000001
#define NIL -1
int min(int a,int b){	return (a<b?a:b);	}
int max(int a,int b){	return (a>b?a:b);	}
int cmp(const void *a ,const void *b){
	int *a1 = (int *)a;
	int *b1 = (int *)b;
	if((*a1) > (*b1))	return 1;
	if((*a1) == (*b1))	return 0;
	return -1;
}
int a[4];
int main(){
	int n;
	char c;
	s(n);
	For(i ,n){
		scanf(" %c" ,&c);
		if(c == 'P')	a[0]++;
		else if(c == 'W')	a[1]++;
		else if(c == 'G')	a[2]++;
		else a[3]++;
	}
	puts(a[3] ? "Four" : "Three");
	return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 10000000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

//#define DEBUG

int main_(){
  string S;
  cin>>S;

  int Max=0;
  for(int i=0;i<S.size();i++){
    for(int j=i;j<S.size();j++){
      bool flg=true;
      for(int k=i;k<=j;k++){
        if(S[k]!='A'&&S[k]!='C'&&S[k]!='G'&&S[k]!='T')flg=false;
      }
      if(flg)Max=max(Max,j-i+1);
    }
  }
  cout<<Max<<endl;
  return 0;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  vector<string>test;
  /*
   * input for debug
   */
  for(int i=0;i<test.size();++i){
    stringbuf buf;
    streambuf*out=cout.rdbuf(&buf);
    cout<<test[i]<<flush;
    cout.rdbuf(out);
    streambuf*in=cin.rdbuf(&buf);
    main_();
    cin.rdbuf(in);
    cout<<endl;
  }
#else
  main_();
#endif

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
using ll=long long;

int main(){
    ll N, K;
    cin >> N >> K;
    ll one; 
    for(ll i = 0; i < N; ++i){
        ll tmp1;
        cin >> tmp1;
        if(tmp1 == 1) one = i;
    }
    if((N - 1) % (K - 1) == 0) cout << (N - 1) / (K - 1) << endl;
    else cout << (N + K - 2) / (K - 1) << endl;
}

Measured memory_bytes: 256