akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

string s[101];
int p[101][101];
int res[101][101][101][101];
inline int sum(int lx, int rx, int ly, int ry) {
  if (lx > rx || ly > ry) return 0;
  return p[rx + 1][ry + 1] - p[rx + 1][ly] - p[lx][ry + 1] + p[lx][ly];
}
int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  int n, m; cin >> n >> m;
  rep(i, n) cin >> s[i];
  rep(i, n) 
    rep(j, m) 
      p[i + 1][j + 1] = p[i][j + 1] + p[i + 1][j] + (s[i][j] == 'o') - p[i][j];
  int cx, cy;
  rep(x, n) rep(y, m) if (s[x][y] == 'E') cx = x, cy = y;

  //rep(x, n) rep(y, m) res[x][x][y][y] = s[x][y] == 'o';
  drep(lx, n) rep(rx, lx, n) drep(ly, m) rep(ry, ly, m) {
    int clx = max(cx - (n - 1 - rx), lx), crx = min(cx + lx, rx); 
    int cly = max(cy - (m - 1 - ry), ly), cry = min(cy + ly, ry);


    if (lx >= clx && lx <= crx)  
      smax(res[lx][rx][ly][ry], res[lx + 1][rx][ly][ry] + sum(lx, lx, cly, cry));
    else smax(res[lx][rx][ly][ry], res[lx + 1][rx][ly][ry]);

    if (rx > 0) {
      if (rx >= clx && rx <= crx)
        smax(res[lx][rx][ly][ry], res[lx][rx - 1][ly][ry] + sum(rx, rx, cly, cry));
      else smax(res[lx][rx][ly][ry], res[lx][rx - 1][ly][ry]);
    }

    if (ly >= cly && ly <= cry) 
      smax(res[lx][rx][ly][ry], res[lx][rx][ly + 1][ry] + sum(clx, crx, ly, ly));
    else smax(res[lx][rx][ly][ry], res[lx][rx][ly + 1][ry]);

    if (ry > 0) {
      if (ry >= cly && ry <= cry)
        smax(res[lx][rx][ly][ry], res[lx][rx][ly][ry - 1] + sum(clx, crx, ry, ry));
      else smax(res[lx][rx][ly][ry], res[lx][rx][ly][ry - 1]);
    }
  }
  
  cout << res[0][n - 1][0][m - 1] << endl;
  return 0;
}


Measured memory_bytes: 201856
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define MAX 10000
#define INF (1 << 21)
#define WHITE  1
#define GRAY  2
#define BLACK  3
using namespace std;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra(){
  priority_queue<pair<int, int> > pq;

  vector<int> color(MAX);
  vector<int> d(MAX);
  
  for(int i = 0; i < n; i++){
    d[i] = INF;
    color[i] = WHITE;
  }

  d[0] = 0;

  pq.push(make_pair(0, 0));

  color[0] = GRAY;

  while(!pq.empty()){
    pair<int, int> f = pq.top();
    pq.pop();

    int u = f.second;

    color[u] = BLACK;

    if(d[u] < f.first * (-1)) continue;

    for(int i = 0; i < adj[u].size(); i++){
      int v = adj[u][i].first;

      if(color[v] == BLACK) continue;
      if(d[v] > d[u] + adj[u][i].second){
	d[v] = d[u] + adj[u][i].second;
	pq.push(make_pair(d[v] * (-1), v));
	color[v] = GRAY;
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << (d[i] == INF ? -1:d[i]) << endl;
  }
}

int main()
{
  int k, u, v, c;

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> u >> k;

    for(int j = 0; j < k; j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;

}



Measured memory_bytes: 8020
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi w(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
    }
    for (int i = 1; i < n; ++i) {
        w[i] += w[i - 1];
    }
    int ret = w[n - 1];
    for (int i = 0; i < 100; ++i) {
        int temp1 = w[i];
        int temp2 = w[n - 1] - w[i];
        chmin(ret, abs(temp1 - temp2));
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double PI=acos(-1.0);
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int c=b*100;
	int ret=0;
	for(int i=0;i<c;i++){
		double t=0.005+(double)i/100;
		double tm=(double)a*PI/180+PI*2*t*60/2500000;
		double mx=cos(tm)*380000;
		double my=sin(tm)*380000;
		double tv=PI/2+PI*2*t/120;
		double vx=cos(tv)*1900;
		double vz=sin(tv)*1900;
		double px=mx+vx;
		double py=my;
		double pz=vz;
	//	printf("%f %f %f\n",px,py,pz);
		double left=0;
		double right=1;
		bool ok=false;
		for(int j=0;j<50;j++){
			double m1=(left+left+right)/3;
			double m2=(left+right+right)/3;
			double d1=sqrt((px*m1-mx)*(px*m1-mx)+(py*m1-my)*(py*m1-my)+(pz*m1)*(pz*m1));
			double d2=sqrt((px*m2-mx)*(px*m2-mx)+(py*m2-my)*(py*m2-my)+(pz*m2)*(pz*m2));
			if(d1<d2)right=m2;
			else left=m1;
			if(min(d1,d2)<1800)ok=true;
		}
		if(ok)ret++;
	}
	printf("%.2f\n",(double)ret/100);
}

Measured memory_bytes: 1068
/*input
1 1000000000000000000
*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 1e9+7;
ll dp[65][2][2][2];
vi numt,numb;
ll fun(ll pos,ll ft,ll fb,ll nz)// f=0 means 
{
	if(pos>=sz(numt)) return nz;
	if(dp[pos][ft][fb][nz]!=-1) return dp[pos][ft][fb][nz];

	ll limt = 1;
	if(ft==0) limt=numt[pos];

	ll limb=0;
	if(fb==0) limb=numb[pos];

	ll ans=0;
	rep(j,limb,limt+1)
	{
		rep(i,limb,limt+1)
		{
			if(j==1 && i==0) continue;

			ll f_new_t=1;
			if(ft==0 && (i==limt || j==limt )) f_new_t=0;
			ll f_new_b=1;
			if(fb==0 && (i==limb||j==limb)) f_new_b=0;

			ll nz_new=nz;
			if(nz==0 && i!=0) nz_new=1;
			if(nz==0 && j==0 && i==1) continue;

			ans = ans+fun(pos+1,f_new_t,f_new_b,nz_new);
			if(ans>=mod) ans-=mod;
		}
	}

	return dp[pos][ft][fb][nz]=ans;
}

int solve()
{
	ll l,r;cin>>l>>r;
	// ll cnt=0;
	// rep(i,l,r+1) rep(j,l,r+1) if((i^j)==(i%j)) cnt++; //cout<<i<<" "<<j<<"\n";
	// whatis(cnt);
	memset(dp,-1,sizeof dp);

	while(r) numt.pb(r%2),r/=2;
	reverse(numt.begin(), numt.end());

	while(l) numb.pb(l%2),l/=2;
	while(sz(numb)<sz(numt)) numb.pb(0);
	reverse(numb.begin(), numb.end());

	ll ans1 = fun(0,0,0,0);
	cout<<ans1<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);


	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#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(args...)		42
#endif


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


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int ceil2(int a, int b){
    int c = a / b;
    if (c * b < a) c++;
    return c;
}

int black(int cur, int par);

int n;

const int lmt = 100007;

vector<int> g[lmt];

vector<int> mem_w(lmt, -1);

vector<int> mem_b(lmt, -1);

int white(int cur, int par)
{
	if(mem_w[cur] != -1)
		return mem_w[cur];

	mem_w[cur] = 1;

	for(auto v: g[cur])
	{
		if(v==par)
			continue;

		mem_w[cur] *= ((white(v, cur)+black(v, cur))%mod);
		mem_w[cur] %= mod;
	}

	return mem_w[cur];
}

int black(int cur, int par)
{
	if(mem_b[cur] != -1)return mem_b[cur];

	mem_b[cur] = 1;

	for(auto v: g[cur])
	{
		if(v==par) continue;

		mem_b[cur] *= (white(v, cur)%mod);
		mem_b[cur] %= mod;
	}

	return mem_b[cur];
}


int32_t main()
{
	c_p_c();

	cin>>n;

	for (int i = 0; i < n-1; ++i)
	{
		int s,d; cin>>s>>d; s--,d--;

		g[s].pb(d);
		g[d].pb(s);
	}

	white(0,-1);
	black(0,-1);

	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << mem_w[i] << " ";
	// }
	// cout << "\n";

	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << mem_b[i] << " ";
	// }

	// cout << "\n";

	cout << (mem_w[0] + mem_b[0]) % mod;
	
	return 0;
}

Measured memory_bytes: 17132
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

const int maxn = 100*1000+5, maxc = maxn;

int Y, X, n, x[maxn], y[maxn];
ll a[maxn], deltay[maxn], deltax[maxn];
std::vector<int> yy[maxc], xx[maxc];
bool seen[maxn], seeny[maxn], seenx[maxn];

ll miny, minx;
void go(int i) {
    seen[i] = true;
    while (!yy[y[i]].empty()) {
        int j = yy[y[i]].back();
        yy[y[i]].pop_back();
        if (!seenx[x[j]]) {
            seenx[x[j]] = true;
            deltax[x[j]] = deltax[x[i]] + a[j] - a[i];
            domin(minx, deltax[x[j]]);
        } else if (deltax[x[j]] != deltax[x[i]] + a[j] - a[i]) {
            printf("No\n");
            exit(0);
        }
        if (!seen[j]) go(j);
    }
    while (!xx[x[i]].empty()) {
        int j = xx[x[i]].back();
        xx[x[i]].pop_back();
        if (!seeny[y[j]]) {
            seeny[y[j]] = true;
            deltay[y[j]] = deltay[y[i]] + a[j] - a[i];
            domin(miny, deltay[y[j]]);
        } else if (deltay[y[j]] != deltay[y[i]] + a[j] - a[i]) {
            printf("No\n");
            exit(0);
        }
        if (!seen[j]) go(j);
    }
}

int main() {
    scanf("%d%d%d", &Y, &X, &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d%lld", y+i, x+i, a+i);
        yy[y[i]].pb(i);
        xx[x[i]].pb(i);
    }

    for (int i = 0; i < n; i++) if (!seen[i]) {
        miny = minx = 0;
        seeny[y[i]] = seenx[x[i]] = true;
        go(i);
        if (a[i] < -minx -miny) {
            printf("No\n");
            exit(0);
        }
    }
    printf("Yes\n");
}


Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T,T MOD,T B>
struct RollingHash{
  using ll = long long;
  vector<T> hash,p;
  RollingHash(){}
  RollingHash(vector<T> vs){init(vs);}
  RollingHash(string &s){
    vector<T> vs;
    for(char c:s) vs.emplace_back(c);
    init(vs);
  }
  void init(vector<T> vs){
    int n=vs.size();
    hash.assign(n+1,0);
    p.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=((ll)hash[i]*B+vs[i])%MOD;
      p[i+1]=(ll)p[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=(ll)hash[r]+MOD-(ll)hash[l]*p[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};

//INSERT ABOVE HERE
signed main(){
  int n,m;
  cin>>n>>m;
  string s;
  cin>>s;
  const int MOD = 1e9+7;
  const int B1 = 1e8+7;
  const int B2 = 1777771;
  RollingHash<int, MOD, B1> rh1(s);
  RollingHash<int, MOD, B2> rh2(s);

  int l=0,r=1;
  set<pair<int, int>> sp;
  for(int i=0;i<m;i++){
    string t;
    cin>>t;
    if(t=="L++") l++;
    if(t=="L--") l--;
    if(t=="R++") r++;
    if(t=="R--") r--;
    sp.emplace(rh1.find(l,r),rh2.find(l,r));
  }

  cout<<sp.size()<<endl;
  return 0;
}



Measured memory_bytes: 21752
#include <iostream>

int main()
{
  int a, b, c;
  int k;

  std::cin >> a >> b >> c;
  std::cin >> k;

  int max = 0;

  max = a;

  if (max < b) {
    max = b;
  }

  if (max < c) {
    max = c;
  }
  int pus = a + b + c - max;

  for (int i = 0; i < k; ++i) {
    max = max*2;
  }

  max = max + pus;

  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] array = Console.ReadLine().Split(' ');
            List<long> nums = new List<long>();
            foreach (string v in array)
            {
                nums.Add(long.Parse(v));
            }
            Console.WriteLine(nums.Min() + " " + nums.Max() + " " + nums.Sum());
        }
    }
}

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

using namespace std;

using ll = long long;

ll Solve() {
    ll n, m;
    cin >> n >> m;
    for (ll k = m / n; 1 <= k; --k) {
        if (k * n == m) return k;
        ll res = m - k * (n - 1);
        if (res % k == 0) return k;
    }
    return 1;
}

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

    cout << Solve() << endl;

    return 0;
}


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

int main()
{
	int a, b; cin >> a >> b;

	string ans = "No";

	for (int i = 1; i <= 3; i++) {

		if (a * b * i % 2 != 0) {

			ans = "Yes";
			break;

		}

	}

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

Measured memory_bytes: 256
#include<stdio.h>
   int n;
   int main()
   {
   long long int a[30];
   while(~scanf("%d",&n))
      {
      for(int i=0;i<n;i++)
	     {
	     scanf("%lld",&a[i]);	
	     }
      int sum=0;
	  for(int i=1;i<n-1;i++)
	     {
	     if((a[i-1]>a[i]&&a[i]>a[i+1])||(a[i-1]<a[i]&&a[i]<a[i+1]))
		    {
		    sum++;
		    }	
	     }
	  printf("%d\n",sum); 	
      }	
   return 0;   
   } 

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

int main() {
	int n; cin >> n;
	rep(i,25) {
		rep(j,15) {
			if(i*4+j*7==n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

namespace ConsoleApp2
{

    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = input[0];
            int N = input[1];

            if (N == 0)
            {
                Console.WriteLine(X);
                return;
            }

            int[] num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i <= 100; i++)
            {
                if (!num.Contains(X - i))
                {
                    Console.WriteLine(X - i);
                    return;
                }
                if (!num.Contains(X + i))
                {
                    Console.WriteLine(X + i);
                    return;
                }
            }


        }
    }
}


    




Measured memory_bytes: 28292
#include <stdio.h>
#include <string.h>

int main(void){
    char str[1001] , ch[1001] ;
    int q , a , b ;
    int i , j ;
    char order[8] ;
    scanf("%s" , str) ; 
    scanf("%d" , &q) ;
    
    for(i = 0 ; i < q ; i++){
        scanf("%s %d %d" , order , &a , &b) ;
        
        if(strcmp(order , "replace") == 0){
            scanf("%s" , ch) ;
            for(j = a ; j <= b ; j++){
                str[j] = ch[j - a] ;
            }
        }
        
        if(strcmp(order , "reverse") == 0){
            for(j = a ; j <= b ; j++){
                ch[b - j] = str[j] ;
            }
            for(j = a ; j <= b ; j++){
                str[j] = ch[j - a] ;
            }
        }
        
        if(strcmp(order , "print") == 0){
            for(j = a ; j <= b ; j++){
                printf("%c" , str[j]) ;
            }
            printf("\n") ;
        }
    }
    return 0 ;
}


Measured memory_bytes: 2132
import math 
def countDigit(n): 
    return math.floor(math.log(n, 10)+1) 
n=int(input())
d=n%10
l=[2,4,5,7,9]
m=[0,1,6,8]
if(d in l):
  print("hon")
elif(d in m):
  print("pon")
else:
  print("bon")

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

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

int main(){
  int x,y;
  cin>>x>>y;
  
  if(y%2!=0||x*2>y||y<0||x*4<y)
    cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S,str = "CODEFESTIVAL2016";
    cin >> S;
    int cnt = 0;
    for(int i = 0;i < S.length();i++){
        if(S[i] != str[i])cnt++;
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005, md = 1000000000 + 7;
int n, x[N], y[N], m;
typedef long long cc;
cc sx[N], sy[N];
cc a, b;
cc process(int n, int x[], cc sx[]) {
    cc sum = 0;
    for (int i = n; i; i--)
        sx[i] = (sx[i + 1] + x[i]) % md;
    for (int i = 1; i <= n; i++)
        sum = (sum + md + sx[i] - (1ll * (n - i + 1) * x[i]) % md) % md;
    return sum;
}
int main() {
//    freopen("input.inp", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> x[i];
    for (int i = 1; i <= m; i++) cin >> y[i];
    sort (x + 1, x + n + 1);
    sort (y + 1, y + m + 1);
    a = process(n, x, sx);
    b = process(m, y, sy);
    cout << (a * b) % md;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>

bool check_circle(int w, int h, int x, int y, int r){
    
    if(0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h) return true;
    else return false;
    
}
int main(){
    int w, h, x, y, r;
    std::cin >> w >> h >> x >> y >> r;
    
    if(check_circle(w, h, x, y, r)){
        std::cout << "Yes" << std::endl;
        return 0;
    }
    else{
        std::cout << "No" << std::endl;
        return 0;
    }
}


Measured memory_bytes: 3116
N = int(input())
s = [int(input()) for _ in range(N)]

res = sum(s)

s.sort()

if res % 10 != 0:
    print(res)
else:
    for i in range(N):
        if (res - s[i]) % 10 != 0:
            print(res - s[i])
            exit()
    print(0)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int main(){
    int i,n,m;
    cin >> n >> m;
    if(n&1){
        for(i=0;i<m;i++){
            cout << i + 1 << " " << n - i << endl;
        }
    }else{
        bool flag = false;
        for(i=0;i<m;i++){
            if(n - 2*i - 1<=n/2 && !flag){
                n--; flag = true;
            }
            cout << i + 1 << " " << n - i << endl;
        }
    }
}

Measured memory_bytes: 3568
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();
    let d = read::<i32>();
    println!(
        "{}",
        std::cmp::max(0, std::cmp::min(b, d) - std::cmp::max(a, c))
    );
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char G[10][10];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  rep(i,h-1){
    rep(j,w-1){
      if(G[i][j]=='#'&&G[i][j+1]=='#'&&G[i+1][j]=='#'){
        cout<<"Impossible"<<endl;
        return 0;
      }
      if(G[i+1][j]=='#'&&G[i][j+1]=='#'&&G[i+1][j+1]=='#'){
        cout<<"Impossible"<<endl;
        return 0;
      }
    }
  }
  cout<<"Possible"<<endl;
}


Measured memory_bytes: 256
line = gets.chomp.to_i
last_num = line.to_s.split('').last.to_i

if [2, 4, 5, 7, 9].include?(last_num)
  puts 'hon'
elsif[0, 1, 6, 8].include?(last_num)
  puts 'pon'
else
  puts 'bon'
end


Measured memory_bytes: 14316
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  ll N, K, a, b;
  cin >> N >> K;
  map<ll,ll> m;
  for( int i=0; i<N; i++ ){
    cin >> a >> b;
    m[a] += b;
  }
  ll c = 0;
  for( map<ll,ll>::iterator it = m.begin(); it != m.end(); ++it ){
    c += it->second;
    if( c >= K ){
      cout << it->first << endl;
      break;
    }
  }
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  
  vector<vector<int>> c(3,vector<int>(3,0));
  for(int i=0;i<3;++i){
    for(int j=0;j<3;++j){
      cin>>c[i][j];
    }
  }
  
  int a1=0;
  int b1=c[0][0]-a1;
  int b2=c[0][1]-a1;
  int b3=c[0][2]-a1;
  int a2=c[1][0]-b1;
  int a3=c[2][0]-b1;
  
  if(a2+b2==c[1][1] && a2+b3==c[1][2] && a3+b2==c[2][1] && a3+b3==c[2][2])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define maxn 1000000000000000000
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;

int main()
{
    fast;

    ll n,ans=0,i,j;
    cin>>n;
    for(i=2;i*i <= n;i++)
    {
    	ll cn=0;
    	while(n%i==0)
    	{
    		n /= i;
    		cn++;
    	}
    	ll ha = 1;
    	while(1)
    	{
    		if(cn - ha >= 0)
    		{
    			ans++;
    			cn -= ha;
    			ha++;
    		}
    		else break;
    	}
    }
    if(n!=1) ans++;
    cout<<ans;

}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n;
vector<int>arr(3025);
int dp[3033][3033][2];
int solve(int i ,int j ,int turn)
{
    if(i>j)
      return 0;
    
    if(dp[i][j][turn]!= -1)
      return dp[i][j][turn];

    if(turn==1)
      return dp[i][j][turn] = max((arr[i]+solve(i+1,j,0)),(arr[j]+solve(i,j-1,0)));
    else
      return dp[i][j][turn] = min(solve(i+1,j,1),solve(i,j-1,1));
}
signed main(void)
{
   
   cin>>n;
   int sum = 0;
   for(int  i = 1;i<=n;i++){
    cin>>arr[i];
    sum+=arr[i];
   }
   memset(dp , -1 ,sizeof dp);
   int ret = solve(1,n,1);
   sum-=ret;
   cout<<ret-sum<<endl;

}

Measured memory_bytes: 144128
#include<iostream>
#include<vector>
#include<algorithm>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;



int main() {
	int a[5];
	int k;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cin >> k;
	rep0(i, 5) {
		for (int j = i; j < 5; j++) {
			if (abs(a[i] - a[j]) > k) {
				cout << ":(";
				return 0;
			}
		}
		
	}
	cout << "Yay!";

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#include<queue>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<int,int> P;
int ceil(int a,int b){// a以上bの倍数の最小値//
     return (a+b-1)/b*b;
 }
int stoii(string s){//stoi関数の代用 文字列⇒int型//
    return atoi(s.c_str());
}

int R,C;
int sy,sx;
int gy,gx;
string c[51];
void solve(){
	queue<P> qp;
	qp.push({sy,sx});
}
int dp[1010][1010]={0};
int main(){
	int n,k;
	cin>>n;
	int i=n;
	while(1){
		if(i%2==0 && i%n==0){
			cout<<i<<endl;
			return 0;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

abcd = list(STR())
for i in range(4):
    abcd[i] = int(abcd[i])
op = ['+', '-']
ops = ['+', '+', '+']
for ops[0] in op:
    for ops[1] in op:
        for ops[2] in op:
            tmp = abcd[0]
            for i in range(3):
                if ops[i] == '+':
                    tmp += abcd[i+1]
                else:
                    tmp -= abcd[i+1]
                if tmp == 7:
                    ans = str(abcd[0])
                    for i in range(3):
                        ans += ops[i] + str(abcd[i+1])
                    ans += '=7'
                    print(ans)
                    exit()

Measured memory_bytes: 5144
import sys
readline = sys.stdin.readline

DIV = 998244353
N,S = map(int,readline().split())
A = list(map(int,readline().split()))

# ある数の取り得る状態は以下
# (1)Lの区間がまだ開始していない
# (2)L-Rの区間に含まれ、和に使われている
# (3)L-Rの区間に含まれ、和に使われていない
# (4)Rの区間が終了している

# dp[i][j][k] = i - 1個目まで処理したときに、区間の開始状況がjで、総和がkになっている個数
dp = [[[0] * (S + 1) for j in range(3)] for i in range(N + 1)]
dp[0][0][0] = 1

for i in range(N):
  for k in range(S + 1):
    # (1)まだ区間が開始していない場合
    dp[i + 1][0][k] += dp[i][0][k]
    dp[i + 1][0][k] %= DIV

    # (2)区間に含まれ、和に使われている(開始していない区間からくる)
    if k + A[i] <= S:
      dp[i + 1][1][k + A[i]] += dp[i][0][k]
      dp[i + 1][1][k + A[i]] %= DIV

    # (2)区間に含まれ、和に使われている(開始済みの区間からくる)
    if k + A[i] <= S:
      dp[i + 1][1][k + A[i]] += dp[i][1][k]
      dp[i + 1][1][k + A[i]] %= DIV
      
    # (3)区間に含まれ、和に使われていない（開始していない区間からくる）
    dp[i + 1][1][k] += dp[i][0][k]
    dp[i + 1][1][k] %= DIV
    
    # (3)区間に含まれ、和に使われていない（開始済みの区間からくる）
    dp[i + 1][1][k] += dp[i][1][k]
    dp[i + 1][1][k] %= DIV

    # (4)区間が終了している（開始済みの区間からくる）
    dp[i + 1][2][k] += dp[i][1][k]
    dp[i + 1][2][k] %= DIV
    
    # (4)区間が終了している（終了済みの区間からくる）
    dp[i + 1][2][k] += dp[i][2][k]
    dp[i + 1][2][k] %= DIV

print((dp[-1][1][-1] + dp[-1][2][-1]) % DIV)

Measured memory_bytes: 287276
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

unordered_map<long, unordered_set<long>> joint;
unordered_map<long, bool> used;

void solve() {
  long N, K;
  cin >> N >> K;
  rep (i, N-1) {
    long a, b;
    cin >> a >> b;
    joint[a].insert(b);
    joint[b].insert(a);
  }
  long result = 1;

  // node 1
  result *= K;
  result %= MOD;
  used[1] = true;

  queue<pair<long, long>> q;

  long count = 1;
  for (auto it: joint[1]) {
    result *= (K - count);
    result %= MOD;
    count ++;
    used[it] = true;
    long __count = 2;
    for (auto __it: joint[it]) {
      if (used[__it]) continue;
      q.push(make_pair(__it, K - __count));
      __count ++;
    }
  }

  while (q.size() > 0) {
    auto current = q.front();
    q.pop();
    result *= current.second;
    result %= MOD;
    used[current.first] = true;
    long __count = 2;
    for (auto __it: joint[current.first]) {
      if (used[__it]) continue;
      q.push(make_pair(__it, K - __count));
      __count ++;
    }
  }

  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 25160
#include <bits/stdc++.h>
#define N 100001
using namespace std;
int A[N],num[N];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i],num[A[i]]++;
  sort(A,A+n);
  //for(int i=0;i<n;i++)cout<<A[i]<<" ";cout<<endl;

  int ans=0,cnt=0;
  vector<int>v;
  for(int i=0;i<N;i++){
    if(num[i]==0)continue;
    if(num[i]%2==0)v.push_back(num[i]);
    else cnt+=num[i]-1,ans++;
  }

  /*  sort(v.begin(),v.end());
  int top=v.size()-1;
  for(int i=0;i<(int)v.size();i++){
    if(v[i]==2&&i<top){
      ans+=2;
      cnt+=v.back()-2;
      v.pop_back();
    }
    else{
      while(i<top&&v[top]==2)top--;  
      if(i==top){
	ans+=(v.size()-i)/2;
	
	ans+=min(l,cnt-cnt%2);
	break;
      }
      v[top]-=2;
      cnt+=v[i]-2;
      ans++;
    }
  }
  */
  ans+=v.size()-v.size()%2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
a=set()
for i in range(m):
  a.add(int(input()))

dp = [0]*(n+1)
dp[0] = 1
if 1 not in a:
  dp[1] = 1

for i in range(2,n+1):
  if i in a:
    continue

  dp[i] += dp[i-1] + dp[i-2]
  dp[i] = dp[i] % 1000000007
print(dp[n])

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

using namespace std;

#define pb push_back
#define fi first
#define se second

const int N = 105, mod = 1e9 + 7;
int n, h[N];

void add (int &_a, int _b) {
    assert(_b >= 0 && _b < mod);
    _a += _b;
    if (_a >= mod) _a -= mod;
}

int binPow (int _a, int _n) {
    int ret = 1;
    for (; _n; _n >>= 1, _a = 1LL * _a * _a % mod) if (_n & 1) ret = 1LL * ret * _a % mod;
    return ret;
}

pair<int, int> solve (int l, int r) {
    int minH = mod;

    bool rect = 1;
    for (int i = l; i + 1 <= r; ++i) if (h[i] != h[i + 1]) rect = 0;

    if (rect) return { ( (binPow(2, r - l + 1) + binPow(2, min(h[l] - h[l - 1], h[r] - h[r + 1]) ) ) % mod - 2 + mod) % mod,
                      binPow(2, min(h[l] - h[l - 1], h[r] - h[r + 1]) ) };

    for (int i = l; i <= r; ++i) minH = min(minH, h[i]);
    vector< pair<int, int> > dp;
    vector< pair<int, int> > range;
    for (int i = l, lst = -1; i <= r; ++i) {
        if (h[i] == minH) lst = -1;
        else {
            if (lst == -1) lst = i;
            if (i == r || h[i + 1] == minH) dp.pb( { solve(lst, i) } );
        }
    }
    for (int i = l, lst = -1; i <= r; ++i) {
        if (h[i] > minH) lst = -1;
        else {
            if (lst == -1) lst = i;
            if (i == r || h[i + 1] > minH) range.pb( { lst, i } );
        }
    }

//    cout << "l = " << l << "  r = " << r << '\n';
//    for (auto _ : dp) cout << _.fi << ' '; cout << '\n';

    pair<int, int> ret = { 0, 0 };

    int tmp = 1;
    for (auto _ : dp) tmp = 1LL * tmp * ( (_.fi + _.se) % mod) % mod;
    for (auto _ : range) tmp = 1LL * tmp * binPow(2, _.se - _.fi + 1) % mod;

//    cout << "tmp = " << tmp << '\n';

    add(ret.fi, tmp);

    tmp = 1;
    for (auto _ : dp) tmp = 1LL * tmp * _.se % mod;
    add(tmp, tmp);

//    cout << "tmp = " << tmp << '\n';

    add(ret.fi, 1LL * tmp * ( (binPow(2, minH - max(h[l - 1], h[r + 1]) - 1) - 1 + mod) % mod) % mod);

    add(ret.se, 1LL * tmp * binPow(2, minH - max(h[l - 1], h[r + 1]) - 1) % mod);

//    cout << ret.fi << "  " << ret.se << '\n';

    return ret;
}

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

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> h[i];

    cout << solve(1, n).fi;

    return 0;
}
/*
3
4 2 5

320
*/


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>

using namespace std;

typedef long long tnum;

#define loop(i, num) for(int i = 0; i < num; i++)

tnum* tnumAlloc(int num);
tnum getNumStdin();
tnum* getNumsStdin(int);
char* getCharsStdin(int maxlength);
string getStringStdin();
void printlnNums(int count, tnum* nums);
void printlnNum(tnum num);
void printString(string str);

#define min(a,b) (a <= b ? a : b)
#define max(a,b) (a >= n ? a : b)

/*void sort(T* start, T* end) (in <algorithm>)
example:
	int a[5] = {2, 1, 3, 5, 4};
	sort(a, a + 5);
	-> a: {1, 2, 3, 4, 5}
*/

tnum gcd(tnum a, tnum b) {
  if(a < b) return gcd(b, a);
  tnum r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    tnum total = 0;
    tnum k = getNumStdin();
    
    loop(a, k){
        loop(b, k){
            loop(c, k){
                tnum g1 = gcd(a+1, b+1);
                tnum g2 = gcd(g1, c+1);
                total += g2;
            }
        }
    }

    printf("%lld", total);

    return 0;
}

//------------------------------

//have to be free()
tnum* tnumAlloc(int num) {
	return (tnum*)calloc(num,sizeof(tnum));
}

tnum getNumStdin() {
	tnum ret;
	scanf("%lld", &ret);

	return ret;
}

//have to be free()
tnum* getNumsStdin(int num) {
	tnum* buf;
	tnum* tmp;
	buf = tnumAlloc(num);
	for (int i = 0; i < num; i++) {
		scanf("%lld", &buf[i]);
	}

	return buf;
}

//have to be free()
char* getCharsStdin(int maxlength) {
	char* ret = (char*)malloc(maxlength+1);
	scanf("%s", ret);

	return ret;
}

//have to be free()
string getStringStdin() {
	string ret;
	cin >> ret;
	return ret;
}

void printlnNum(tnum num) {
	printf("%lld\n", num);
}

// can be used for debugging
void printlnNums(int count, tnum *nums) {
	loop(i, count) {
		printf("%lld", nums[i]);
		if (i != count - 1) printf(" ");
	}
	printf("\n");
}

void printString(string str) {
	cout << str;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,p;
int main() {
	ll i,ans,cnt,p,j;
	cin>>n>>p;
	ans=1;
	for (i=2;i*i<=p;i++)
		if (p%i==0) {
			cnt=0;
			while (p%i==0) cnt++,p/=i;
			for (j=1;j<=cnt/n;j++)	ans*=i;
		}
	if (p>1&&n==1) ans*=p;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
連結リスト
"""
from collections import deque

N = int(input())

que = deque()
for i in range(N):
    instr =  input()
    if instr == 'deleteFirst':
        que.popleft()
    elif instr == 'deleteLast':
        que.pop()
    else:
        com, num = instr.split()
        if com == 'insert':
            que.appendleft(num)
        elif com == 'delete':
            try:
                que.remove(num)
            except ValueError:
                pass
print(*que)



Measured memory_bytes: 69744
n = int(input())
li = list(map(int, input().split()))
box = [0 for x in range(max(li)+1)]
for i in li:
    box[i] += 1
count = 1

if len(box) > 2:
    for i in range(1, len(box)-1):
        count *= box[i] ** box[i+1]
        count %= 998244353
else:
    count = 1
    
if box[0] != 1 or li[0] != 0:
    count = 0

print(count % 998244353)

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

int GCD(int a, int b);

int main(){
	int N, X, i;
	cin >> N >> X;
	int x[N];
	x[0]=X;
	
	int Min = x[0], MinNum;
	
	for(i=1; i<=N; i++){
		cin >> x[i];
		if(Min > x[i]){
			Min = x[i];
			MinNum=i;
		}
	}
	
//	cout << "Min=" << Min << endl;
	
	int sa[N], gap[N], j=0;
	for(i=0; i<=N; i++){
		sa[i] = x[i]-Min;
//		cout << "gap[i]=" << gap[i] << endl;
		if(sa[i]!=0){
			gap[j]=sa[i];
			j++;
		}
	}
	
/*	
	for(i=0; i<N; i++){
		cout << "gap=" << i << " " << gap[i] << endl;
	}
*/
	//ここまでおっけなはず
	
	
	//最大公約数GCD
	for(i=0; i<N-1; i++){
//		cout << "i=" << i << endl;
//		if(gap[i]!=0 && gap[i+1]!=0){
			int A=GCD(gap[i], gap[i+1]);
			gap[i+1]=A;
//			cout << A << endl;
//		}
	}
	
	cout << gap[N-1] << endl;
	
	return 0;
}

int GCD(int a, int b){
//	cout << "GCD " << a << " " << b << endl;
	int tmp;
	if(a<b){
		tmp=a;
		a=b;
		b=tmp;
	}
	
	int r;
	r=a%b;
	while(r!=0){
		a=b;
		b=r;
		r=a%b;
	}
	
//	cout << "b=" << b << endl;
	return b;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        string s;
        cin >> s;
        int k;
        cin >> k;
        set<string> st;
        for (int len = 1; len <= k; len ++) {
                for (int i = 0; i < (int) s.size() - len + 1; i ++) {
                        st.insert(s.substr(i, len));
                }
        }
        vector<string> v;
        for (auto it : st) {
                v.push_back(it);
        }
        sort(v.begin(), v.end());
        cout << v[k - 1] << endl;
        return 0;
}



Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <set>
#include <tuple>

int main() {
    std::set<std::tuple<char, int>> cards;

    int n;
    std::cin >> n;

    char suit;
    int number;
    for (int i = 0; i < n; i++) {
        std::cin >> suit >> number;
        cards.insert(std::make_tuple(suit, number));
    }

    std::vector<char> suits = {'S', 'H', 'C', 'D'};
    for (char suit : suits) {
        for (int i = 1; i <= 13; i++) {
            if (cards.find(std::make_tuple(suit, i)) == cards.end()) {
                std::cout << suit << " " << i << std::endl;
            }
        }
    }
}



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

struct BinaryIndexedTree
{
  vector< int64 > data;
  int curr;
  
  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
    curr = 1;
    while(curr < data.size()) curr <<= 1;
    for(int i = 0; i < data.size(); i++) data[i] = i & -i;
  }
  inline int64 sum(int k)
  {
    int64 ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return(ret);
  }
  inline int upper_bound(int64 w)
  {
    int i = 0;
    for(int k = curr; k > 0; k >>= 1) {
      if(i + k < data.size() && data[i + k] <= w) {
        w -= data[i + k];
        i += k;
      }
    }
    return(i);
  }
  inline void add(int k, int64 x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
 
int N, Q;
int X[200000], D[200000], L[200000];
char buff[32];

int main()
{
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < Q; i++) {
    scanf("%d %d %d", &X[i], &D[i], &L[i]);
  }
  BinaryIndexedTree xpy(N), xmy(N);
  for(int i = Q - 1; i >= 0; i--) {
    if(D[i] == 1) {
      xmy.add(0, -L[i] * 2);
      xmy.add(xpy.upper_bound(X[i]), L[i] * 2);
    } else {
      xpy.add(xmy.upper_bound(X[i]), L[i] * 2);
    }
  }
  for(int i = 0; i < N; i++) {
    printf("%lld\n", (xpy.sum(i) - xmy.sum(i)) / 2);
  }
}

Measured memory_bytes: 6548
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int A[100000];
int B[100000];
int C[100000];
int main(){
  int i;
  rd(N);
  rd(K);
  for(i=(0);i<(N);i+=(2)){
    A[i] = K++;
  }
  for(i=(1);i<(N);i+=(2)){
    A[i] = K++;
  }
  for(i=(1);i<(N);i+=(2)){
    B[i] = K++;
  }
  for(i=(0);i<(N);i+=(2)){
    B[i] = K++;
  }
  for(i=(0);i<(N);i++){
    C[i] = K++;
  }
  for(i=(0);i<(N);i++){
    if(A[i]+B[i] > C[i]){
      wt_L(-1);
      wt_L('\n');
      return 0;
    }
  }
  for(i=(0);i<(N);i++){
    wt_L(A[i]);
    wt_L(' ');
    wt_L(B[i]);
    wt_L(' ');
    wt_L(C[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191108-1

// --- original code ---
// int N, K;
// int A[1d5], B[1d5], C[1d5];
// {
//   rd(N,K);
//   rep(i,0,N,2) A[i] = K++;
//   rep(i,1,N,2) A[i] = K++;
//   rep(i,1,N,2) B[i] = K++;
//   rep(i,0,N,2) B[i] = K++;
//   rep(i,N) C[i] = K++;
// 
//   rep(i,N) if(A[i]+B[i] > C[i]) wt(-1), return 0;
//   rep(i,N) wt(A[i],B[i],C[i]);
// }


Measured memory_bytes: 3456
#include<stdio.h>
#include<math.h>

int main(){
  int D, N;

  scanf("%d %d", &D, &N);

  if(N!=100){
    printf("%d\n", (int)pow(100,D)*N);
  }else{
    printf("%d\n", (int)pow(100,D)*(N+1));
  }
  return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

// Nの桁数
int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    // 再帰的に解く (x, y を入れ替えておく)
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

//約数列挙
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

ll num[1010];

class CFactorsOfFactorial {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        ll n;cin>>n;
        for (ll i=2;i<=n;i++) {
            const auto &pf = prime_factorize(i);
            for (auto p:pf) num[p.first]=(num[p.first]+p.second)%MOD;
        }
        ll ans=1;
        for (int i=2;i<=n;i++) {
            ans=ans*(num[i]+1)%MOD;
        }
        cout<<ans<<endl;
    }
};


int main() {
	CFactorsOfFactorial solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <cmath>
#include <complex>
#include <cfloat>

using namespace std;

#define INFD numeric_limits<double>::infinity()
#define INFL (int)1e8
#define INFLL (long long)1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

int main() {
  int n; cin >> n;
  vll a(n); Loop(i, n) cin >> a[i];
  ll val[2];
  Loop(i, n) {
    val[a[i] % 2]++;
  }
  if (val[1] % 2) {
    cout << "NO" << endl;
  }
  else cout << "YES" << endl;
}

Measured memory_bytes: 1024