akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<queue>
using namespace std;
#define N 100002
int dis1[N],dis2[N];
int vis[N];
vector<int> g[N];
queue<int> q;
int dir[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
void BFS1() //从哪个节点开始 
{
	int i,now;
	int st; 
	while( !q.empty() )
	{
		st = q.front();
		q.pop();
		for( i=0;i<g[st].size();i++ )
		{
			now = g[st][i];
			if( vis[now] )
				continue;
			vis[now]=1;
			dis1[now] = dis1[st] + 1;
			q.push(now);
		}
	}
}
void BFS2() //从哪个节点开始 
{
	int i,now;
	int st; 
	while( !q.empty() )
	{
		st = q.front();
		q.pop();
		for( i=0;i<g[st].size();i++ )
		{
			now = g[st][i];
			if( vis[now] )
				continue;
			vis[now]=1;
			dis2[now] = dis2[st] + 1;
			q.push(now);
		}
	}
}
int main(){
	int to,from,i,n;
	cin>>n;
	for( i=0;i<n-1;i++ ){
		cin>>to>>from;
		g[to].push_back(from);
		g[from].push_back(to);
	}
	q.push(1);
	BFS1();
	memset(vis,0,sizeof(vis));
	q.push(n);
	BFS2();
	int cntF=0;
	for( i=1;i<=n;i++ )
	{
		if( dis1[i]<=dis2[i] )
			cntF++;
	}
	int cntS = n-cntF;
	if( cntF>cntS )
		cout<<"Fennec\n";
	else
		cout<<"Snuke\n";
	return 0;
}


Measured memory_bytes: 7040
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


int main()
{
	ll r, d, x; cin >> r >> d >> x;

	REP1C(i, 10)
	{
		x = r * x - d;
		cout << x << endl;
	}
}


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

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] X = new int[M];
		for (int i = 0; i < M; i++) {
			X[i] = sc.nextInt();
		}

		if (M <= N) {
			System.out.println(0);
			return;
		}

		Arrays.sort(X);

		int[] diff = new int[M - 1];
		for (int i = 1; i < X.length; i++) {
			diff[i - 1] = X[i] - X[i - 1];
		}

		Arrays.sort(diff);

		int sum = 0;
		for (int i = 0; i < diff.length - N + 1; i++) {
			sum += diff[i];
		}

		System.out.println(sum);;
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 49444
#include<iostream>
#include <string>
using namespace std;
int main()
{
  int a=0,b=0,t;
  string s,res;
  cin >> s;
  t=stoi(s.substr(0,2));
  if(t>=1&&t<=12) a=1;
  t=stoi(s.substr(2,2));
  if(t>=1&&t<=12) b=1;
  if(a&&b) res="AMBIGUOUS";
  else if(a) res="MMYY";
  else if(b) res="YYMM";
  else res="NA";
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int a; string s;
	cin>>a; cin>>s;
	if(a>=3200) cout<<s<<endl;
	else cout<<"red"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,m;
	while(1){
	cin>>n>>m;
	if(n==0 || m==0){
		break;
	}
	int dat[1100],cnt=0,x,ans=0;
	for(int i=0;i<n;i++){
		cin>>dat[i];
	}
	for(int i=0;i<m;i++){
		cin>>x;
		cnt+=x;
		ans++;
		if(cnt>=n){
			for(int j=i+1;j<m;j++){
				cin>>x;
			}
			break;
		}
		cnt+=dat[cnt];
		if(cnt>=n){
			for(int j=i+1;j<m;j++){
				cin>>x;
			}

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


}

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

#define int long long

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int cnt = n / i;
        ans += i * cnt + cnt * (cnt - 1) / 2 * i;
    }
    cout << ans;
    return 0;
}


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

using namespace std;

#define pb push_back

typedef long long ll;

int n, G;
int a[51], b[51];
vector<ll> has[51], nhas[51];

void go(int a, int b, int c, ll cur) {
    // cout << a << " "<< b << " " << c << " "<< cur << endl;
    if (a == b) {
        // cout << cur << endl;    
        has[G].pb(cur);
        // cout << has[0][0] << endl;
        return;
    }
    c = min(c, a);
    for (int i = c; i >= 1; i--) {
        int rem = a % i;
        if (rem < b) continue;
        go(rem, b, i, cur + (1ll << i));
    }
}

void changeHas(int pos) {
    for (int i = 0; i < n; i++) {
        nhas[i].clear();
        for (int j = 0; j < has[i].size(); j++) {
            if ((has[i][j] & (1ll << pos)) == 0) {
                // if (i == 2 && j == 1) cout << has[i][j] << endl;
                // if (pos < 10 && i == 2) cout << pos << " " << has[2][0] << endl;
                nhas[i].pb(has[i][j]);
            }   
            // else if (i == 2 && j == 1) cout << pos << endl;
        }
        has[i] = nhas[i];
    }
}

int main() {
    // freopen("inp.txt", "r", stdin);

    cin >> 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++) {
        G = i;
        go(a[i], b[i], a[i], 0);               
        if (has[i].size() == 0) {
            cout << -1;
            return 0;
        }
        // cout << has[i].size() << endl;
    }
    // cout << has[0][0] << endl;
    // cout << has[2].s << endl;
    // for (int i = 0; i < has[0].size(); i++) {
    //     if (has[0][i] == 160) cout << "Here" << endl;
    // }
    ll ans = 0;
    for (int i = 50; i >= 0; i--) {
        int ok = 1;
        for (int j = 0; j < n; j++) {
            int shit = 0;
            for (int t = 0; t < has[j].size(); t++) {
                if ((has[j][t] & (1ll << i)) == 0) {
                    shit = 1;
                    break;
                }
            }
            // if (i == 50 && j == 0) {
            //     cout << (has[j][0] & (1ll << i)) << endl;
            // }
            if (!shit) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            changeHas(i);
        }
        else {
            // cout << i << endl;
            ans += (1ll << i);
        }
    }

    cout << ans;

    return 0;
}

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

struct SegmentTree {
    int n;
    vector<int> node;
    SegmentTree(vector<int> v) {
        n = 1;
        while (n < v.size()) n *= 2;
        node.resize(2*n-1, -INT_MAX);
        for (int i=0; i<v.size(); ++i) node[i+n-1] = v[i];
        for (int i=n-2; i>=0; --i) node[i] = max(node[i * 2 + 1], node[i * 2 + 2]);
    }
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2*n-1, -INT_MAX);
    }
    // x番目の要素をvalに更新
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // [a, b)の中の要素の最小値を答える
    // k := 自分がいるノードのインデックス
    int query(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return -INT_MAX;
        if (a <= l and r <= b) return node[k];
        int vl = query(a, b, 2*k+1, l, (l+r)/2);
        int vr = query(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


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

    vector<int> a(N);
    rep(i, N) cin >> a[i];

    SegmentTree seg(a);

    rep(i, N) {
        if (i == 0) cout << seg.query(1, N) << endl;
        else if (i == N-1) {
            //cout << 0 << ", " << N-1 << ", " << seg.query(0, N) << endl;
            cout << seg.query(0, N-1) << endl;
        }
        else {
            cout << max(seg.query(0, i), seg.query(i+1, N)) << endl;
        }
    }
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,M; cin >> N >> M;
    vector<pair<int,int>> A(M);
    rep(i,M)cin >> A[i].S >> A[i].F;

    sort(all(A));

    int ans = 0;
    int endtime = 0;
    rep(i,M){
        if(A[i].S >= endtime){
            endtime = A[i].F;
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


//階乗先に計算
class Kaizyou{
    public:
    long long int *kaizyou;
    Kaizyou(){};
    Kaizyou(long long int n,long long int mod){
        kaizyou=new long long int[n+1];
        kai(1,n,mod);
        return;
    }

    long long int kai(long long int a, long long int b, long long int mod) {
        long long int tmp = 1;
		kaizyou[0]=1;
        for (long long int i = a; i <= b; i++) {
            tmp *= i;
            tmp %= mod;

            kaizyou[i] = tmp;
        }
        return tmp;
    }
};

//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
class Ruizyou{
    public:
    long long int rui(long long int a, long long int b, long long mod) {
        int memo[65] = {};
        long long int A[65] = {};
        long long int tmp = 1;
        for (int i = 0; i < 65; i++) {
            memo[i] = b % 2;
            b /= 2;
        }

        A[0] = a;
        A[0] %= mod;

        for (int i = 1; i < 65; i++) {
            A[i] = A[i - 1] * A[i - 1];
            A[i] %= mod;
        }
        for (int i = 0; i < 65; i++) {
            if (memo[i] == 1) {
                tmp *= A[i];
                tmp %= mod;
            }
        }
        tmp %= mod;
        return tmp;
    }
};
//コンビネーション計算
class Combination{
    public:
        Kaizyou * Kaizyou_Instance;
        Ruizyou Ruizyou_Instance;
    Combination(long long int n,long long int mod){
        Kaizyou_Instance=new Kaizyou(n,mod);
    }
    long long int comb(long long int n, long long int r, long long int mod) {
        long long int tmp;
		if(r>n){return 0;}
        tmp = (Kaizyou_Instance->kaizyou[n] * Ruizyou_Instance.rui(Kaizyou_Instance->kaizyou[r], mod - 2, mod)) % mod;
        tmp *= Ruizyou_Instance.rui(Kaizyou_Instance->kaizyou[n - r], mod - 2, mod);
        tmp %= mod;
        if (tmp < 0) { tmp = (mod - tmp) % mod; }
        return tmp;
    }
};	

string N;
long long int r1,r2,c1,c2,res=0;

int main() {
	cout << fixed << setprecision(18);
	cin>>r1>>c1>>r2>>c2;
	Combination comb(2000005,mod);
	Kaizyou kai(2000005,mod);
	Ruizyou rui;
	long long int tmpc2=rui.rui(kai.kaizyou[c2],mod-2,mod),tmpc1;
	if(c1!=1){tmpc1=rui.rui(kai.kaizyou[c1-1],mod-2,mod);}
	for(int i=r1+1;i<=r2+1;i++){
		long long int Iinv=rui.rui(kai.kaizyou[i],mod-2,mod);
		res+=((((kai.kaizyou[i+c2])*tmpc2)%mod)*Iinv)%mod;
		if(c1-1>0)res-=((((kai.kaizyou[i+c1-1])*tmpc1)%mod)*Iinv)%mod;
		else if(c1==1){res--;}
	}
	
	res%=mod;
	cout<<(mod+res)%mod;
} 

Measured memory_bytes: 31488
#include<iostream>
#include<cstdio>
using namespace std;
#define MAXN 100000
typedef long long ll;
int n,k;
ll T[MAXN];

int check(ll P)
{
	int i = 0;
	for (int j = 0; j < k; ++j)
	{	
		ll s = 0;
		while(s+T[i]<=P)
		{
			s += T[i];
			i++;
		}
		if (i==n)
		{
			return i;
		}
	}
	return i;
}

int solve()
{
	ll left = 0;
	ll right = 10000*100000;
	ll mid;
	while( right-left > 1)
	{
		mid = (right+left)/2;
		int v = check(mid);
		if (v>=n)
		{
			right = mid;
		}
		else left = mid;
	}
	return right;
}
int main(int argc, char const *argv[])
{
	cin>>n>>k;
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld",&T[i]);//cin>>T[i];
	}
	/*ll P = solve();
	cout<<P<<endl;*/
	cout<<solve()<<endl;
	return 0;
}


Measured memory_bytes: 3948
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com

#include<bits/stdc++.h>

using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
typedef long long int LL;
typedef unsigned long long int ULL;
template<typename T>
 T gcd(T a,T b)
{
    return b==0?a:gcd(b,a%b);
}
template<typename T>
 T lcm(T a,T b)
{
    LL g=gcd(a,b);
    return (a/g)*b;
}
int main()
{
//    fast;
    int i,j,k,n,l,s=0,tc=1,c=0;
    while(cin>>n)
    {
        vl a;
        LL x,y,m=1;
        rep(i,n)
        {
           vp(a,x);
        }
        rep(i,n)
        {
            m=lcm(m,a[i]);
        }
        cout<<m<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
     int flag=1;
    while(b<=a && k!=0)
    {
        b*=2;
        k--;
    }
    if(k<=0 && c<=b)
        flag=0;
    while(c<=b && k!=0)
    {
        c*=2;
        k--;
    }
    if(c>b && b>a && flag==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    

}

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

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

  if (N >= 1000) {
    cout << "ABD";
    // cout << setfill('0') << setw(3) << N - 999 << endl;
  }
  else {
    cout << "ABC";
    // cout << setfill('0') << setw(3) << N << endl;
  }
  cout << endl;
}


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

using namespace std;

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

    int port = 1;

    int check;
    while(true){
        if(port>=B){
            break;
        }

        port += A-1;

        check++;
    }

    cout << check << endl;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,K,ans; cin >> N >> K;
  ans = 0LL;
  if(K==0LL){
    cout << N*N << endl;
    return 0;
  }
  REP(b,K+1,N+1){
    ans += (b-K)*(N/b);
    ll temp = N % b;
    ans += max(0LL,temp-K+1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//112 B - Time Limit Exceeded 2018/10/06
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int N , T;
    cin >> N >> T;
    vector<pair<int,int>> x(N);
    rep(i ,N) cin >> x[i].first >> x[i].second;
    int min=2000000000; int counter=0;
    rep(i ,x.size()){
        if(x[i].second>T) ++counter;
        if(x[i].second<=T){
            if(min>x[i].first) min=x[i].first;
        }
    }
    if(counter==x.size()) { cout << "TLE" << endl; return 0; }
    cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[30];
bool vis[30];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(len<26){
		for(int i = 1;i<=len;i++){
			vis[s[i]-'a']=1;
		}
		for(int i = 0;i<26;i++){
			if(!vis[i]){
				s[len+1]='a'+i;
				break;
			}
		}
		for(int i = 1;i<=len+1;i++){
			cout<<s[i];
		}
		return 0;
	}
	int jud=26;
	for(int i = 25;i;i--){
		if(s[i]-'a'>s[i+1]-'a'){
			if(jud==i+1) jud=i;
		}
	}
	if(jud==1){
		puts("-1");
		return 0;
	}
	char t='z';
	for(int i = jud;i<=len;i++){
		if(s[i]-'a'>s[jud-1]-'a'){
			if(s[i]-'a'<t-'a'){
				t=s[i];
			}
		}
	}
	s[jud-1]=t;
	for(int i = 1;i<jud;i++) cout<<s[i];
	return 0;
}

Measured memory_bytes: 256
import static java.util.Comparator.*;

import java.util.*;

public class Main {
    private class Span {
        int s, t, c;

        public Span(int s, int t, int c) {
            this.s = s;
            this.t = t;
            this.c = c;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int c = sc.nextInt();
        List<Span> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(new Span(sc.nextInt(), sc.nextInt(), sc.nextInt()));
        }

        list.sort(comparing(o -> ((Span) o).s).thenComparing(
            comparing(o -> ((Span) o).t).reversed()));

        int cnt = 0;
        while (!list.isEmpty()) {
            cnt++;
            int nowt = 0;
            int nowc = 0;
            for (Iterator<Span> ite = list.iterator(); ite.hasNext();) {
                Span channel = ite.next();
                if ((nowt < channel.s) || (nowt == channel.s && nowc == channel.c)) {
                    nowt = channel.t;
                    nowc = channel.c;
                    ite.remove();
                }
            }
        }

        System.out.println(cnt);
    }

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


Measured memory_bytes: 99744
// 2014/02/06 Tazoe

#include <iostream>
using namespace std;

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

	int S[100000];
	S[0] = 0;
	for(int i=1; i<n; i++){
		int s;
		cin >> s;

		S[i] = S[i-1]+s;
	}

	int sum = 0;

	int X = 1;
	for(int i=0; i<m; i++){
		int a;
		cin >> a;

		if(a>0){
			sum += (S[X+a-1]-S[X-1]);
		}
		else{
			sum += (S[X-1]-S[X+a-1]);
		}
		sum %= 100000;

		X = X+a;
	}

	cout << sum << endl;

	return 0;
}

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

int main(){
  int A, B, C, X; //a 500円玉 b 100円玉 c 50円玉
  cin >> A >> B >> C >> X;
  int count = 0;
  
  for(int a = 0; a <= A; a++){
    for(int b = 0; b <= B; b++){
      for(int c = 0; c <= C; c++){
        int total = 500*a + 100*b + 50*c;
        if(total == X) count++;
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element



//---------- 1000000007 ----------
const int MOD = 1000000007;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_divide(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}
int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_divide(p, i);
	}
	return p;
}
int m_comb_with_rep(int n, int r)
{
	return m_comb(n + r - 1, r);
}



int N;
int A[300010];

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	int ans = 0;
	for (int i = 0; i < 60; i++)
	{
		int n0 = 0;
		int n1 = 0;
		for (int j = 0; j < N; j++)
		{
			if ((A[j] & (1LL << i)) == 0)
				n0++;
			else
				n1++;
		}
		int s = m_mul(n0, n1);
		int b = (1LL << i) % MOD;
		int a = m_mul(b, s);
		ans = m_add(ans, a);
	}
	cout << ans << endl;
}



Measured memory_bytes: 5912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, x;
    cin >> n >> x;
    int l = 1, r = 2*n - 1;
    if (x == l || x == r) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        vector<int> ans(2*n - 1);
        iota(ans.begin(), ans.end(), 1);
        if (x <= n) {
            rotate(ans.rbegin(), ans.rbegin() + (n - x), ans.rend());
        } else {
            rotate(ans.begin(), ans.begin() + (x - n), ans.end());
        }
        rep(i, ans.size()) cout << ans[i] << endl;
    }
}


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

typedef long long ll;
string S, T;
ll R;

int main() {
  cin >> S >> T;
  for (ll i = 0; i < 3; ++i) {
    if (S[i] == T[i]) ++R;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
// In the name of Allah. Ya ali!
#include<bits/stdc++.h>
#define double long double
typedef long long ll;
const ll MAX_N = 2e5+10;
const ll MOD = 1e9+7;
using namespace std;

int cnt1[MAX_N];
int cnt2[MAX_N];

int main()
{
    string s;
    int n;
    cin >> n >> s;
    for(int i = 1;i<=n;++i)
        cnt1[i] = cnt1[i-1]+(s[i-1]=='#');
    for(int i = n;i>=1;--i)
        cnt2[i] = cnt2[i+1]+(s[i-1]=='.');
    int ans = n;
    for(int i = 0;i<=n;++i)
        ans = min(ans,cnt1[i]+cnt2[i+1]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 2180
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int s[100010];

bool compare(const int &a, const int &b)
{
	return a < b;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(s[i]));
	
	sort(s, s + n, compare);
	
	s[n] = 10000;
	
	long long count = 0;
	for (int i = 0 ; i < n ; i++)
		for (int j = i + 1 ; j < n ; j++)
		{
//			printf("%d %d\n", s[i], s[j]);
			
			int sum = s[i] + s[j];
			int rPos = lower_bound(s, s + n, sum) - s;
			
//			if (rPos >= n)
//				rPos = n - 1;
			if (s[rPos] >= sum)
				rPos--;
			
			int secCount = rPos - j;// - 1;
			
//			int diff = s[j] - s[i] + 1;
//			int lPos = lower_bound(s, s + n, diff) - s;
//			
//			int secCount = rPos - lPos + 1;
//			if ((s[lPos] <= s[j]) && (s[j] <= s[rPos]))
//				secCount--;
//			if ((s[lPos] <= s[i]) && (s[i] <= s[rPos]))
//				secCount--;
				
			if (secCount <= 0)
				continue;
			
//			printf("%d %d %d\n", i, j, secCount);
//			printf("%d %d\n", i, j);			
//			printf("%d\n", secCount);
			count = count + secCount;
		}
		
	printf("%lld\n", count);
	
	
	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())

uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)

ans = 0

for i in range(N):
    ans = max(ans, uf.size(i))
    
print(ans)

Measured memory_bytes: 79676
import numpy as np
from numba import njit
N=int(input())
a=np.array([int(i) for i in input().split()],dtype=np.int64)

s=[0]

dp=np.array([[-1 for i in range(N)] for _ in range(N)],dtype=np.int64)

for i in range(1,N+1):
    s.append(s[i-1]+a[i-1])

s=np.array(s,dtype=np.int64)
for i in range(N):
    dp[i][i]=0

@njit('i8(i8,i8,i8[:,:],i8[:])', cache=True)
def calc(i,j,dp,s):
    if dp[i][j]!=-1:
        return dp[i][j]
    m=10**14
    for k in range(i,j):
        m=min(m,calc(i,k,dp,s)+calc(k+1,j,dp,s)+s[j+1]-s[i])
    dp[i][j]=m
    return dp[i][j]

print(calc(0,N-1,dp,s))

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

int main()
{
	vector<int> r;
	int _r;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> _r;
		r.push_back(_r);
	}
	int minval = r[0];
	int maxval = -2000000000;
	for (int j = 1; j < n; j++)
	{
		maxval = max(r[j] - minval, maxval);
		minval = min(minval, r[j]);

	}
	cout << maxval << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int a[4];
	rep(i, 4) a[i] = s[i] - '0';
	rep(b, 8) {
		int x = a[0];
		string ans;
		ans += s[0];
		rep(i, 3) {
			if ((b >> i) & 1) {
				x += a[i + 1];
				ans += '+';
				ans += s[i + 1];
			}
			else {
				x -= a[i + 1];
				ans += '-';
				ans += s[i + 1];
			}
		}
		if (x == 7) {
			ans += "=7";
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pli pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;
ll solve2(string s[], ll r[], ll c[], ll s1, ll s2, ll h, ll w, ll sum, ll k, vector<ll> &v){
	if(s2 == w){
		return (k == sum);
	}
	
	ll so1 = solve2(s, r, c, s1, s2 + 1, h, w, sum, k, v);
	ll temp = sum - c[s2];
	rep(j, 0, v.size()){
		if(s[v[j]][s2] == '#')
			temp++;
	}
	ll so2 = solve2(s, r, c, s1, s2 + 1, h, w, temp,k, v);

	return so1 + so2;
}
ll solve(string s[], ll r[], ll c[], ll s1, ll s2, ll h, ll w, ll sum, ll k, vector<ll> &v){
	if(s1 == h){
		return solve2(s, r, c, s1, s2, h, w, sum, k, v);
	}
	
	ll so1 = solve(s, r, c, s1 + 1, s2, h, w, sum, k, v);
	v.pb(s1);
	ll so2 = solve(s, r, c, s1 + 1, s2, h, w, sum - r[s1], k, v);
	v.pop_back();
	return so1 + so2;
}

int main(){
    FASTIO
    ll h, w, k;
    cin >> h >> w >> k;
    string s[h];
    ll row[h] = {0}, col[w] = {0};
    ll sum = 0;
	rep(i, 0, h){
    	cin >> s[i];
    	ll c = 0;
    	rep(j, 0, w){
    		if(s[i][j] == '#')
    			c++;
		}
		row[i] = c;
		sum += c;
	}
	rep(j, 0, w){
		ll c = 0;
		rep(i, 0, h){
			if(s[i][j] == '#')
				c++;
		}
		col[j] = c;
	}
    vector<ll> v;
    cout << solve(s, row, col, 0, 0, h, w, sum, k, v);
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))
l = [0]
mod = 10 ** 9 + 7
s = sum(a)
cur = 0
ans = 0
for i in range(n):
    cur += a[i]
    ans += (a[i] * (s - cur)) % mod
    ans %= mod
print(ans)

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 998244353;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, s;
    cin >> n >> s;
    vl a(n);
    cin >> a;

    vector<vector<ll>> dp(n + 1, vl(s + 1));
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, s + 1) {
            // a[i] を和の計算に使わないとき
            dp[i + 1][j] += (dp[i][j] * 2) % mod;
            dp[i + 1][j] %= mod;
            // a[i] を和の計算に使うとき
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= mod;
            }
        }
    }
    cout << dp[n][s] << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 73696
n = int(input())
s = [input() for i in range(n)]

ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0
for i in range(len(s)):
    if s[i] == 'AC':
        ac_count += 1
    elif s[i] == 'WA':
        wa_count += 1
    elif s[i] == 'TLE':
        tle_count += 1
    elif s[i] == 'RE':
        re_count += 1

print('AC x ',ac_count)
print('WA x ',wa_count)
print('TLE x ',tle_count)
print('RE x ',re_count)


Measured memory_bytes: 16332
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ***********************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ***********************************/
/******* Main ****************************************/
void Main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vi vec(m);
  vvi matrix(n, vi(m));

  rep(i, 0, n) {
    rep(j, 0, m) cin >> matrix[i][j];
  }

  rep(i, 0, m) cin >> vec[i];

  rep(i, 0, n) {
    ans = 0;
    rep(j, 0, m) {
      ans += vec[j] * matrix[i][j];
    }
    cout << ans << '\n';
  }
}

/*********************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

************************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std; 

int main(){
	string s;
	cin>>s;

	string as[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

	for(int i=0;i<7;i++){
		if(s==as[i]){
			cout<<7-i<<endl;
		}
	}

}

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

using namespace std;

int original[10], compare1[10], compare2[10], targetIndex, size;

bool areEqual(const int array[], const int array2[], int arrSize) {
    for (int i = 0; i < arrSize; i++) {
        if (array[i] != array2[i]) {
            return false;
        }
    }

    return true;
}

int findPermutation(int modified[], int compare[], int arrSize) {
    sort(modified, modified + arrSize);

    do {
        if (areEqual(modified, compare, arrSize)) {
            return targetIndex;
        }

        targetIndex++;
    } while (next_permutation(modified, modified + arrSize));
}


int main() {
    cin >> size;

    for (int i = 0; i < size; i++) {
        original[i] = i + 1;
    }

    for (int i = 0; i < size; i++) {
        cin >> compare1[i];
    }

    for (int i = 0; i < size; i++) {
        cin >> compare2[i];
    }

    targetIndex = 0;
    int perm1 = findPermutation(original, compare1, size);

    targetIndex = 0;
    int perm2 = findPermutation(original, compare2, size);

    cout << abs(perm1 - perm2);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int dx = x2 - x1;
		int dy = y1 - y2;
		int x3 = x2 + dy;
		int y3 = y2 + dx;
		int x4 = x1 + dy;
		int y4 = y1 + dx;
		System.out.println(x3 + " " + y3 + " "  + x4 + " " + y4);
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    int n,k,d,p,ans=0; cin>>n>>k;
    vi a(n+1, 0);
    NA(i,0,k){
        cin>>d;
        NA(i,0,d) cin>>p, a[p]++;
    }
    NA(i,1,n+1) if(!a[i]) ans++;
    cout<<ans;
    return ;
}
int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

/* -----  2017/06/10  Problem: ABC 064 B / Link: http://abc064.contest.atcoder.jp/tasks/abc064_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;
int a[200];
ll ans = 0LL;

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

  cin >> N;
  FOR(i, 0, N)cin >>a[i];
  sort(a, a + N);
  ans = a[N-1] - a[0];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())

count = [0]*(N+1)
for i in range(1, N+1):
    for k in range(i+1, N+1):
        distik = min(k-i, abs(k-X) + abs(i - Y)+1, abs(k-Y) + abs(i-X)+1)
        count[distik] += 1

for i in range(1, N):
    print(count[i])


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

#define IL inline 
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

const int mod = 1e9 + 7;
IL int mul(int x, int y) { return 1ll * x * y % mod; }
IL int pls(int x, int y) { x += y; return x >= mod ? x - mod : x; }
IL int dec(int x, int y) { x -= y; return x < 0 ? x + mod : x; }
IL int fpw(int x, int y) {
	int rtn = 1;
	for (; y; y >>= 1, x = mul(x, x))
		if (y & 1) rtn = mul(rtn, x);
	return rtn;
}
IL int inv(int x) { return fpw(x, mod - 2); }

const int maxn = 2e5 + 10;
int fac[maxn];

IL int C(int x, int y) { if (x == 0) return 1; return mul(fac[x], mul(inv(fac[y]), inv(fac[x - y]))); }
IL int Sol(int x, int y) { 
	return C(x + y - 2, x - 1); 
}
int main() {
	
	int n, m, a, b;
	fac[0] = 1;
	for (int i = 1; i < maxn; ++i) fac[i] = mul(fac[i - 1], i);
	
	n = read(), m = read(), a = read(), b = read();
	
	int ans = 0;
	for (int i = b + 1; i <= m; ++i) {
		ans = pls(ans, mul(Sol(n - a, i), Sol(a, m - i + 1)));
	}

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

Measured memory_bytes: 1024
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

void main() {
  long n = readln.chomp.to!long;
  long[] a = readln.chomp.split.to!(long[]);
  long[] count = new long[n];
  foreach(ai;a) count[ai-1]++;
  foreach(ci;count) writeln(ci);
}


Measured memory_bytes: 11676
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    X, Y, Z = mi()
    k = X//(Y+Z)
    r = X%(Y+Z)
    if r < Z:
        print(k-1)
    else:
        print(k)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ld EPS=10e-8;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

queue<pair<ll,ll>> Q;
vector<vector<ll>> V(107);
ll chek[107];
ll ans[107];

int main(){
    ll N;
    cin >> N;
    ll A,B,C;
    rep(i,N){
        cin >> A >> B;
        rep(j,B){
            cin >> C;
            V[A].pb(C);
        }
    }
    rep(i,N+1){
        ans[i]=-1;
    }
    Q.push(mp(1,0));
    chek[1]=1;
    while(Q.size()>0){
        rep(i,V[Q.front().first].size()){
            if(chek[V[Q.front().first][i]]==0){
                Q.push(mp(V[Q.front().first][i],Q.front().second+1));
                chek[V[Q.front().first][i]]=1;
            }
        }
        ans[Q.front().first]=Q.front().second;
        Q.pop();
    }
    REP(i,1,N+1){
        cout << i << " " << ans[i] << endl;
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int rd(){
    int a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}
ll rdll(){
    ll a=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))a=(a<<1)+(a<<3)+(ch^48),ch=getchar();
    return a;
}

const int N=100005;

int n,a[5];

int main(){
	for(int i=0;i<6;i++)scanf("%d",&n),++a[n];
	for(int i=1;i<5;i++)if(a[i]>2){printf("NO");return 0;}
	printf("YES");
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	if(S[0]==S[1]) cout << "Bad" << endl;
	else if(S[1]==S[2]) cout << "Bad" << endl;
	else if(S[2]==S[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()


void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}



int main() {
    fast();
    ll q,h,s,d,n;cin>>q>>h>>s>>d>>n;
    ll min1liter=min(q*4,min(h*2,s));
    ll min2liter=min(q*8,min(h*4,min(s*2,d)));
    ll ans=(n/2*min2liter)+(n%2)*min1liter;
    cout<<ans;
}


Measured memory_bytes: 256