akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define min(p,q)((p)<(q)?(p):(q))
#define zahyoutype double
typedef struct Point{zahyoutype x,y;}P;
double distPP(P p,P q){return hypot(p.x-q.x,p.y-q.y);}
double arg(P p,P o){return atan2(p.y-o.y,p.x-o.x);}

void readpoint(P*p){zahyoutype x=1;scanf(x/2?"%lf%lf":"%ld%ld",&p->x,&p->y);}
void printpoint(P p){zahyoutype x=1;printf(x/2?"%.9lf %.9lf\n":"%ld %ld\n",p.x,p.y);}

int main(){
	P p1,p2;
	int r1,r2;
	readpoint(&p1);
	scanf("%d",&r1);
	readpoint(&p2);
	scanf("%d",&r2);
	double dist=distPP(p1,p2);
	double ar=arg(p2,p1);
	double s1=r1*(r1+r2)/dist;
	double s2=r1*(r1-r2)/dist;
	double theta1=acos(s1/r1);
	double theta2=acos(s2/r1);
	P ans[4];
	int cnt=0;
	if(    r1+r2  <dist)ans[cnt].x=p1.x+r1*cos(ar+theta1),ans[cnt].y=p1.y+r1*sin(ar+theta1),cnt++;
	if(    r1+r2 <=dist)ans[cnt].x=p1.x+r1*cos(ar-theta1),ans[cnt].y=p1.y+r1*sin(ar-theta1),cnt++;
	if(abs(r1-r2) <dist)ans[cnt].x=p1.x+r1*cos(ar+theta2),ans[cnt].y=p1.y+r1*sin(ar+theta2),cnt++;
	if(abs(r1-r2)<=dist)ans[cnt].x=p1.x+r1*cos(ar-theta2),ans[cnt].y=p1.y+r1*sin(ar-theta2),cnt++;
	for(int i=0;i<cnt;i++)for(int j=0;j<cnt-1-i;j++){
		if(ans[j].x>ans[j+1].x||ans[j].x==ans[j+1].x&&ans[j].y>ans[j+1].y){
			P temp=ans[j];ans[j]=ans[j+1];ans[j+1]=temp;
		}
	}
	for(int i=0;i<cnt;i++)printpoint(ans[i]);
}


Measured memory_bytes: 2176
n=int(input())
ab=[]
for i in range(n):
    ab.append(list(map(int, input().split())))

ab=sorted(ab, key=lambda x: x[1])

s=0
for i in ab:
    s+=i[0]
    if s > i[1]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 55256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    double a,b,x;
    cout << fixed << setprecision(20);
    cin >> a >> b >> x;
    x /= a;
    double c = x / a;
    double h_sub = b - c;
    if(c >= h_sub){
        cout << atan(2*h_sub/a)*90*2/M_PI << endl;
    }else{
        double d = 2 * x / b;
        cout << atan(b/d)*90*2/M_PI << endl;
    }
}

Measured memory_bytes: 4000
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
struct BIT {
    int N;
    vector<T> dat;

    // 0-indexing
    explicit BIT(int n): N(n), dat(N + 1, 0) {}

    T sum(int i) {
        T s = T();
        for(++i; i > 0; i -= i & -i) s += dat[i];
        return s;
    }

    void add(int i, const T& x) {
        for (++i; i <= N; i += i & -i) dat[i] += x;
    }

    // min_x {x | v1 + v2 + ⋯ + vx ≧ w}
    // Assuming v_q >= 0
    int lower_bound(T w) {
        if (w <= 0) return 0;

        int x = 0; T k = 1;
        while (k * 2 <= N) k <<= 1;
        for (; k > 0; k /= 2) {
            if (x + k <= N && dat[x + k] < w) {
                w -= dat[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, Q;
    cin >> N >> Q;

    vll c(N);
    for(auto &e: c) cin >> e;
    for(auto &e: c) --e;

    vector<vector<pair<int, int>>> query(N);
    REP(i, Q) {
        int l, r; cin >> l >> r;
        --l; --r;
        query[r].eb(l, i);
    }

    vector<int> last(N, -1);
    BIT<int> bit(N);
    vector<int> ans(Q);
    REP(i, N) {
        if (~last[c[i]]) bit.add(last[c[i]], -1);
        last[c[i]] = i;
        bit.add(i, 1);

        for(auto &p: query[i]) {
            ans[p.se] = bit.sum(i) - bit.sum(p.fi-1);
        }
    }

    for (auto &e: ans) cout << e << "\n";

}


Measured memory_bytes: 35228
def main():
  s = list(input())
  num = int(input())
  while num > 0:
    m = list(input().split())
    if m[0] == 'print':
      print(''.join(s[int(m[1]):(int(m[2]) + 1)]))
    elif m[0] == 'reverse':
      temp = s[int(m[1]):(int(m[2]) + 1)]
      temp.reverse()
      for i,v in enumerate(temp):
        s[int(m[1]) + i] = v
    elif m[0] == 'replace':
      temp = list(m[3])
      for i,v in enumerate(temp):
        s[int(m[1]) + i] = v
    num -= 1
main()


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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
set < int > g[N];
set < pair < int, int > > all;
pair < int, int > edge[N];
int u[N];
int cur;

int main () {
	cin >> n >> k;
	
	ll ans = 0;
	For (i, 0, k - 1) {
	    ll cnt = 0;
	    int it = i;
	    if (it == 0) it = k;
	    for (int j = it; j <= n; j += k) {
            ++ cnt;
        }
        
        if((i * 2) % k == 0) ans += cnt * cnt * cnt;
	}
	
	cout << ans;
	
	return Accepted;
}

// Coded By OB

Measured memory_bytes: 29312
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(void){
    // Your code here!
  int n,m;
  cin >> n >> m;
  int count = 0;
  vector<int> A(n);
  rep(i,n) {
      cin >> A[i];
      count += A[i];
     }

  int sum = 0;
  rep(i,n){
      if(A[i]*(4*m) >= count)  sum++;
  }
  if(sum >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ns()

flag = False
for i in range(3):
    if n[i] == '7':
        flag = True

print("Yes" if flag else "No")

Measured memory_bytes: 9184
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef unsigned long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

struct Deep {
	ll all;
	ll notreef;
	ll reef;
};

int main(void) {
	int n;
	ll ans = 1;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(ALL(a));
	if (a[0] == 0) {
		cout << 0;
		return 0;
	}
	rep(i, n) {
		if (a[i] > 1000000000000000000/ans) {
			cout << -1;
			return 0;
		}
		ans *= a[i];
	}
	cout << ans << endl;
}

/*
ans*a[i]>max
a[i]>max/ans
*/


Measured memory_bytes: 4052
N,M = map(int,input().split())
A = [[x for x in input()] for i in range(N)]
B = [[x for x in input()] for i in range(M)]
result = "No"


for i in range(N-M+1):
    for j in range(N-M+1):
        result = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    result = False
        if result:
            print("Yes")
            exit()




print("No")




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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, ans = 0; 
    char op;
    cin >> A >> op >> B;
    if (op == '+') {
        ans = A + B;
    }
    if (op == '-') {
        ans = A - B;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int d = 0;
  int r;
  for (char c : s) {
    if ('0' <= c && c <= '9') {
      d++;
      r += c - '0';
    }
  }
  cout << max(r, d * 9 + s[0] - '0' - 10) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int> >adj;
int dp[2005][2004];
int n,k;
int mn=1e9;

void dfs(int ver,int pr)
{
	for(auto i:adj[ver])
	{
		if(i!=pr)
		{
			dfs(i,ver);
			for(int j=n+1;j>=1;j--)
			{
				dp[ver][j]+=dp[i][j-1];
			}
		}
	}
	dp[ver][0]=dp[ver][1]+1;
}

void dfs2(int ver,int pr)
{
	if(!mn)
		return ;
	mn=min(mn,dp[ver][k/2+1]);
	for(auto i:adj[ver])
	{
		if(k&1)
		mn=min(mn,dp[ver][k/2+1]-(dp[i][k/2]-dp[i][k/2+1]));
	}
	for(auto i:adj[ver])
	{
		if(i!=pr)
		{
			for(int j=n+1;j>=1;j--)
			{
				dp[ver][j]-=dp[i][j-1];
			}
			dp[ver][0]-=dp[i][0];
			for(int j=n+1;j>=1;j--)
			{
				dp[i][j]+=dp[ver][j-1];
			}
			dp[i][0]+=dp[ver][0];

			dfs2(i,ver);

			for(int j=n+1;j>=1;j--)
			{
				dp[i][j]-=dp[ver][j-1];
			}
			dp[i][0]-=dp[ver][0];
			for(int j=n+1;j>=1;j--)
			{
				dp[ver][j]+=dp[i][j-1];
			}
			dp[ver][0]+=dp[i][0];
		}
	}
}


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

     cin>>n>>k;
     adj.resize(n+1);
     int x,y;
     for(int i=0;i<n-1;i++)
     {
     	cin>>x>>y;
     	adj[x].push_back(y);
     	adj[y].push_back(x);
     }

    dfs(1,0);
    dfs2(1,0);
	cout<<mn;

}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int nextl[26][210000];
int best[210000];
int bestl[210000];
int main(){
	string a;
	cin >> a;
	int n = a.size();
	for(int c = 0; c < 26; c++){
		nextl[c][n] = n;
		for(int i = n-1; i >= 0; i--){
			nextl[c][i] = nextl[c][i+1];
			if(a[i] - 'a' == c) nextl[c][i] = i;
		}
	}
	best[n+1] = 0;
	for(int i = n; i >= 0; i--){
		best[i] = 110000000;
		bestl[i] = -1;
		for(int c = 0; c < 26; c++){
			if(best[nextl[c][i] + 1] + 1 < best[i]){
				bestl[i] = c;
				best[i] = best[nextl[c][i] + 1] + 1;
			}
		}
	}
	int r = 0;
	while(r < n){
		if(bestl[r] == -1){
			r++;
		} else {
			cout << (char)(bestl[r] + 'a');
			r = nextl[bestl[r]][r] + 1;
		}
	}
}


Measured memory_bytes: 23428
// Author : Mohamed Sameh
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<stack>
#include<deque>
#include <cstring>
#include <iomanip>    
using namespace std ;
typedef long long ll ;

#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define PI  3.141592 
#define SZ(a) (int)a.size()
void READ (string INPUT = "NO" , string OUTPUT = "NO" )
{
    if (INPUT != "NO")
    freopen(INPUT.c_str() , "r" , stdin );
    if (OUTPUT!="NO")
    freopen ( OUTPUT.c_str() , "w" , stdout);
} 
int n ; 
int a[100001]; 
int dp[100001]; 
int solve (int i)
{
    if (i==n-1)
        return 0 ; 
    if (i >= n)
        return 2e9 ; 
    if (dp[i]!=-1)return dp[i]; 
    int &ret = dp[i]; 
    return ret = min( abs (a[i] - a[i+1]) + solve(i+1) ,abs (a[i]-a[i+2])+solve(i+2));  
    
}
int main ()
{
    memset (dp,-1,sizeof dp );
    scanf ("%d" , &n ); 
    for (int i =0 ; i < n ;i++)
        scanf ("%d" , a+i); 
    printf ("%d\n" , solve(0)); 
    return 0 ; 
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<deque>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define WHITE 0
#define BLACK 1
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
        }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int q,b,e,t;cin>>q;
    for(int i=0;i<q;i++){
        cin>>b>>e>>t;
        for(int i=0;i<e-b;i++) swap(a[b+i],a[t+i]);
    }
    for(int i=0;i<n;i++){
        cout<<a[i]<<(i==n-1?'\n':' ');
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,D,x,y;
    cin>>N>>D;
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>x>>y;
        if(sqrt(pow(x,2)+pow(y,2))<=D){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(){

   int x,y,i;

   for(i=0;i<3000;i++){
      scanf("%d %d",&x,&y);

      if(x==0&&y==0){

          break;

      }


      if(x<=y){
         printf("%d %d\n",x,y);
      }else if(x>y){
         printf("%d %d\n",y,x);
      }
            }

   return 0;

}

Measured memory_bytes: 2744
INF = float("inf")
n, A, B, C = map(int, input().split())
L = tuple(map(int, (int(input()) for _ in range(n))))
def f(a, b, c, num):
    if num == n:
        if min(a, b, c) > 0:
            return abs(A - a) + abs(B - b) + abs(C - c)
        else:
            return INF
    return min(
        f(a + L[num], b, c, num + 1) + (10 if a else 0),
        f(a, b + L[num], c, num + 1) + (10 if b else 0),
        f(a, b, c + L[num], num + 1) + (10 if c else 0),
        f(a, b, c, num + 1)
    )
print(f(0, 0, 0, 0))


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long ll;
typedef long double ld;
typedef unsigned long long int ull;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
ll n, m, k, y, x, d, w = 1, num, sum, ans = 0; string s;
vector<vector<int>> Gragh;
int main(void) {
	cin >> x >> y >> d >> k;
	vector<ll> a(x), b(y), c(d),D,e;
	rep(i, x) cin >> a[i];
	rep(i, y)cin >> b[i];
	rep(i, d) cin >> c[i];
	sort(RALL(a)); sort(RALL(b)); sort(RALL(c));
	rep(i, x) {
		rep(j, y) {
			D.push_back(a[i] + b[j]);
		}
	}sort(RALL(D));
	rep(i, min(k,x*y)) {
		rep(j, d) {
			e.push_back(D[i] + c[j]);
		}
	}sort(RALL(e));
	rep(i, k) cout << e[i] << endl;
}

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

using ll=long long;

int main() {
  int N; cin >>N;
  vector<int> A(N);
  rep(i,0,N) {cin >>A[i];}
  ll ans=0;
  int max_val=0;
  rep(i,0,N) {
    max_val=max(max_val,A[i]);
    ans+=max_val-A[i];
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	string s;
	cin >> s;
	int cnt=0;
	for(int i = 0; i < s.size(); i++) if(s[i]=='x') cnt++;
	if(cnt<8) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = 0
c = 0
for i in a:
    if i % 4 == 0:
        b += 1
    elif i % 2 == 0:
        c += 1
if b >= n // 2:
    print("Yes")
elif c >= (n-2*b):
    print("Yes")
else:
    print("No")

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

int n, T, t[200010];
long long ans;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}

int main()
{
	n = read();
	T = read();
	for(int i = 1; i <= n; i ++)
		t[i] = read();
	int now = 0, st = 0;
	for(int i = 1; i <= n; i ++)
	{
		if(t[i] > now + T) ans += now + T - st, st = t[i], now = t[i];
		else now = t[i];
	}
	ans += now + T - st;
	cout << ans;

	return 0;
}


Measured memory_bytes: 1024
using System ;

namespace Program{
  class Program{
   static void Main(string []args){
     string []buff = Console.ReadLine().Split(' ');
     int A = int.Parse(buff[0]);
     int B = int.Parse(buff[1]);
     int T = int.Parse(buff[2]); 
     
  
     int result = T / A * B ;
     Console.WriteLine(result);
     
   }
  }
}

Measured memory_bytes: 11092
package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	fmt.Println(x2-y2+y1, y2+x2-x1, -y2+y1+x1, x2-x1+y1)
}


Measured memory_bytes: 512
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g[N];
int n, m, k;
int a[N], res;
string ss;

void go(int l, int r){
//	cout << l << " " << r << "\n";
	if (l == r){
		res += g[l].size() / 2;
	}
	else{
		if (g[l].size() < g[r].size()) swap(g[l], g[r]);
		res += min(g[l].size(), g[r].size());
		int val = g[l].size() - g[r].size();
//		cout << val;
		for (int i = 1; i < g[l].size(); i++){
			if (val <= 1) break;
			if (g[l][i] == g[l][i - 1]){
				val -= 2;
				res++;
				i++;
			}
		}
	}
//	cout << endl;
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++){
		g[a[i] % m].pb(a[i]);
	}
	go(0, 0);
	for (int l = 1, r = m - 1; l <= r; l++, r--){
		go(l, r);
	}
	cout << res;
	return 0;
}












Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using Board = vector<vector<int>>;

int W, H;

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

bool inBounds(int x, int y)
{
	if (x < 0 || W <= x) { return false; }
	if (y < 0 || H <= y) { return false; }

	return true;
}

// ?§??????????????????´????????????????????¨?????????
bool mov(Board& b, int x, int y, int dx, int dy, int& nx, int& ny)
{
	while (true) {
		x += dx;
		y += dy;

		if (!inBounds(x, y)) { return false; }

		if (b[y][x] == 1) {
			nx = x - dx;
			ny = y - dy;
			b[y][x] = 0;
			return true;
		}

		if (b[y][x] == 3) {
			nx = x;
			ny = y;
			return true;
		}
	}

	return true;
}

void dfs(Board b, int x, int y, int d, int& ans)
{
	// ??´??????????????????
	if(b[y][x] == 3) {
		ans = min(ans, d);
		return;
	}

	if(d >= 10) { return; }

	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i];
		int ny = y + dy[i];

		if(!inBounds(nx, ny)) { continue; }
		if(b[ny][nx] == 1) { continue; }

		Board nb(b);

		if(!mov(nb, x, y, dx[i], dy[i], nx, ny)) { continue; }

		dfs(nb, nx, ny, d + 1, ans);
	}
}

int main()
{
	while (true) {
		cin >> W >> H;
		if (W == 0 && H == 0) {
			break;
		}

		Board b(H, vector<int>(W, 0));

		int sx, sy;
		int gx, gy;

		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> b[i][j];
				if (b[i][j] == 2) {
					sx = j;
					sy = i;
				}

				if (b[i][j] == 3) {
					gx = j;
					gy = i;
				}
			}
		}

		int ans = 11;
		dfs(b, sx, sy, 0, ans);
		if(ans > 10) {
			cout << -1 << endl;
		} else {
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3180
while(True):
    a, op, b = input().split()
    if(op == '+'):
        print(int(a) + int(b))
    elif(op == '-'):
        print(int(a) - int(b))
    elif(op == '*'):
        print(int(a) * int(b))
    elif(op == '/'):
        print(int(a) // int(b))
    elif(op == '?'):
        break

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int k, x;
    cin >> k >> x;
    for(int i = x-k+1; i <= x+k-1; i++)
        cout << i << " ";
    cout << endl;
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll a=0;
        loop(i,1,n)
        {
            ll x,y;
            cin>>x>>y;
            if(x==y) a++;
            else
            {
                if(a<3) a=0;
                else break;
            }
        }
        if(a>=3) cout<<"Yes";
        else cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3648
if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    import heapq
    from copy import deepcopy

    INFTY = 2**21
    WHITE = 0
    GRAY = 1
    BLACK = 2

    n = int(input())

    adj = [0]*n

    for _ in range(n):
        u, k, *vc = map(int, input().split())
        vc_tuple = [0]*k
        for i, (v, c) in enumerate(zip(vc[::2], vc[1::2])):
            # pythonにはvectorないので、tupleで代用
            vc_tuple[i] = (v, c)
        adj[u] = vc_tuple

    def dijkstra():
        d = [INFTY]*n
        color = [WHITE]*n

        d[0] = 0
        PQ = [(0, 0)]
        heapq.heapify(PQ) # PQを優先度付きキューにする
        color[0] = GRAY
        while PQ:  # PQの長さ0でwhile抜ける
            f = heapq.heappop(PQ)
            u = f[1]
            color[u] = BLACK

            # 最小値を取り出し、それが最短でなければ無視
            if d[u] < f[0]: # -1かけない理由は9行下のコメント参照
                continue

            for adj_u in adj[u]:
                v = adj_u[0]
                if color[v] == BLACK:
                    continue
                if d[v] > d[u]+adj_u[1]:
                    d[v] = d[u]+adj_u[1]
                    # pythonのheapqはmin-ヒープを使っているので-1かけなくて良い
                    heapq.heappush(PQ, (d[v], v))
                    color[v] = GRAY

        for i in range(n):
            print(str(i) + ' ' + str(-1 if d[i] == INFTY else d[i]))

    dijkstra()

    """

    nodes = [[] for _ in range(n)]

    for _ in range(n):
        u, k, *vc = map(int, input().split())
        cv = [0]*k
        for i, (v, c) in enumerate(zip(vc[::2], vc[1::2])):
            cv[i] = (c, v)
        nodes[u] = cv

    d = [INFTY]*n
    d[0] = 0

    d_node = nodes[0]
    heapq.heapify(d_node)

    visited = [False]*n
    visited[0] = True

    while d_node:
        min_c, min_v = heapq.heappop(d_node)
        if visited[min_v]:
            continue
        visited[min_v] = True
        d[min_v] = min_c
        for c, v in nodes[min_v]:
            heapq.heappush(d_node, (min_c+c, v))

    for u, dist in enumerate(d):
        print(str(u) + ' ' + str(dist))
    """



Measured memory_bytes: 68156
process.stdin.resume();
process.stdin.setEncoding("utf8");
    var lines = [];
    var reader = require("readline").createInterface({
        input: process.stdin,
        output: process.stdout
    });
reader.on("line", (line) => {
    lines.push(line);
});

reader.on("close", () => {
    var e = lines[0].split(" "), h = Number(e[0]), a = Number(e[1]);
    var f = lines[1].split(" "), array = [];
    for(var i=0;i<a;i++){
        array.push(Number(f[i]));
    }
    var sum = array.reduce((x, y) => x + y);
    if(sum >= h){
        console.log("Yes");
    }else if (sum < h){
        console.log("No")
    }
    
});

Measured memory_bytes: 32332
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
using namespace std;
//
const int inf=1e9;
//
int N,M,Q,L,R;
int l[1000],r[1000],c[1000],s[1000];
vector<int> V[1000];
int main(){
	cin>>N>>M>>Q;
	for(int i=0;i<M;i++){
		cin>>L>>R;
		L--;R--;
		if(L==R){
			s[L]++;
		}else{
			V[L].push_back(R);
			if(R-L>1){
				c[L+1]++;c[R]--;
			}
			l[L]++;r[R]++;
		}
	}
	//
	sort(V[0].begin(),V[0].end());
	for(int i=1;i<=N;i++){
		sort(V[i].begin(),V[i].end());
		l[i]+=l[i-1];
		r[i]+=r[i-1];
		c[i]+=c[i-1];
		s[i]+=s[i-1];
	}
	while(Q--){
		int p,q;
		cin>>p>>q;
		p--;q--;
		if(p==q){
			cout<<s[q]-(p-1>=0?s[p-1]:0)<<endl;
			continue;
		}
		int left=r[p],right=M-l[q-1];
		int cross=c[p]+c[q],same=s[q]-(p-1>=0?s[p-1]:0);
		for(int i=p-1;i>=0;i--){
			cross-=V[i].size()-(upper_bound(V[i].begin(),V[i].end(),q)-V[i].begin());
		}
		cout<<M-left-right-cross+same<<endl;
	}
	return 0;
}

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

int main() {
  
   int N;
   int R;
   int Na;
       
    cin>>N>>R;
    
    if(N<10)
    {
     
        Na = 100*(10-N);
        cout<<Na+R<<endl;
        
    }
    
    else
    {
        cout<<R<<endl;
    }
    
    
    
    
}
    
    
    
  



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


namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int n = tmp[0];
            int hp = tmp[1];
            int aMax = int.MinValue;
            int[] bArray = new int[n];
            for (int i = 0; i < n; i++)
            {
                tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
                int a = tmp[0];
                if (aMax < a)
                    aMax = a;

                bArray[i] = tmp[1];
            }
            Array.Sort(bArray);
            Array.Reverse(bArray);

            int count = 0;
            for (int index = 0; index < bArray.Length; index++)
            {
                if (bArray[index] < aMax)
                {
                    break;
                }
                hp -= bArray[index];
                count++;
                if (hp <= 0)
                {
                    break;
                }
            }
            count += hp <= 0 ? 0 : (int)Math.Ceiling((double)hp / aMax);
            Console.WriteLine(count);
        }




    }
}


Measured memory_bytes: 17632
N=int(input())
dp=[1 for i in range(0,N)]
data={i:-1 for i in range(1,2*10**5+1)}
mod=10**9+7

c=int(input())
data[c]=0

for i in range(1,N):
    c=int(input())
    if data[c]==i-1:
        dp[i]=dp[i-1]
    elif data[c]==-1:
        dp[i]=dp[i-1]
    else:
        dp[i]=(dp[i-1]+dp[data[c]])%mod
    data[c]=i

print(dp[N-1])


Measured memory_bytes: 64464
#include <iostream>
using namespace std;
int main()
{
    int m, n;
    bool flag;
    while(true)
    {
        cin>>m>>n;
        if(m==0&&n==0)break;
        for(int i=1;i<=m;i++)
        {
            if((i%2)==0){ flag = true;}
            else {flag = false;}
            for(int j=1;j<=n;j++)
            {
                if(flag==false)
                {
                    cout<<'#';
                    flag=true;
                }
                else 
                {
                    cout<<'.';
                    flag=false;
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3080
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def solve(N, A, B):
    max_try = sum(B) - sum(A)

    a_try = 0
    b_try = 0
    for a, b in zip(A, B):
        d = b - a
        if d > 0:
            a_try += (d + 1) // 2
            b_try += d % 2
        elif d < 0:
            b_try += -d

    rest_a_try = max_try - a_try
    rest_b_try = max_try - b_try

    if rest_a_try >= 0 and rest_a_try * 2 == rest_b_try:
        print('Yes')
    else:
        print('No')



def main():
    inputs = sys.stdin.readlines()
    inputs = [s.rstrip('\n').lstrip(' ') for s in inputs]

    N = int(inputs[0])
    a = list(map(int, inputs[1].split()))
    b = list(map(int, inputs[2].split()))

    solve(N, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100010]={};
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+100010);
	reverse(a,a+100010);
	// for(int i=0;i<n;i++){
	// 	cout << i << ":" << a[i] << endl;
	// }
	long long int ans=1;
	int cnt=0;
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			if(cnt<2){
				ans*=a[i];
				a[i]=0;
				a[i+1]=0;
				cnt++;
			}
		}
	}
	if(cnt==0 || cnt==1){
		cout << 0 << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int main()
{
  erep(i, 1, 9) erep(j, 1, 9) cout << i << "x" << j << "=" << i * j << endl;

  return 0;
}

Measured memory_bytes: 1116
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char ch[1001];
    int i;
    int sum;
    int num;
    
    while (1) {
        scanf("%s", ch);
        if (ch[0] == '0') {
            break;
        }
        //一文字ずつ見る
        sum = 0;
        for (i=0; i<1001; i++) {
            if (ch[i] == '\0') break; //文末なら終わる
            num = ch[i] - 48;   //アスキーコードをint型に変換
            sum += num;
        }
        printf("%d\n", sum);
    }
    return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

void Muri(){
	cout<<"Impossible"<<endl;
	exit(0);
}

signed main(){
	int n=read(),m=read();
	vi a,b;
	REP(i,m)
		a.PB(read());
	sort(ALL(a),[](int x,int y){
		return (x&1)>(y&1);
	});
	if(n&1){
		if(m>1&&(a[1]&1))
			Muri();
		for(auto v:a)
			b.PB(v/2*2);
		b.PB(1);
	}else{
		if(m>2&&(a[2]&1))
			Muri();
		if(a[0]&1){
			swap(a[1],a.back());
			for(auto v:a)
				b.PB(v/2*2);
			b.back()+=2;
		}else{
			b.PB(1);
			for(auto v:a)
				b.PB(v/2*2);
			b.back()--;
		}
	}
	vi ans;
	for(auto v:b)
		if(v)
			ans.PB(v);
	REP(i,a.size())
		print(a[i],i<int(a.size()-1)?2:1);
	print(ans.size());
	REP(i,ans.size())
		print(ans[i],i<int(ans.size()-1)?2:1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    double x;
    cin >> x;
    long a = 0;
    unordered_set<long> s;

    for (; ; a++) {
        long y = pow(a, 5);
        bool br = false;
        s.insert(y);
        for (auto j : s) {
            if (y + j == x) {
                br = true;
                break;
            }
            if (y - j == x) {
                br = true;
                break;
            }
        }
        if (br) break;
    }

    long d = pow(a, 5) - x;
    long b = (d >= 0 ? 1 : -1) * pow(abs(d), 0.2);

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


Measured memory_bytes: 4124
#include<stdio.h>
#define P 1000000007
int main(void){
	int n;
	int a,b,c;
	int i;
	long ans=1;
	char s0[100]={0},s1[100]={0};
	int mat[100][100]={0};
	scanf("%d%s%s",&n,s0,s1);
	for(i=0;i<n;i++){
		c=s0[i];
		c=c-'A';
		c=c-('a'-'Z'-1)*(c>30);
		if(mat[c][c]==0) mat[c][c]=3;
		if(i>0){
			a=s0[i-1];
			a=a-'A';
			a=a-('a'-'Z'-1)*(a>30);
			if(mat[a][a]&&mat[a][c]==0&&mat[c][a]==0){
				mat[c][c]--;
				mat[a][c]=1;
				mat[c][a]=1;
				if(i>1&&s0[i-2]==s0[i-1]&&s0[i]==s0[i+1]) mat[c][c]++;
			}
		}
		c=s1[i];
		c=c-'A';
		c=c-('a'-'Z'-1)*(c>30);
		if(mat[c][c]==0) mat[c][c]=3;
		a=s0[i];
		a=a-'A';
		a=a-('a'-'Z'-1)*(a>30);
		if(mat[a][a]&&mat[a][c]==0&&mat[c][a]==0){
			mat[c][c]--;
			mat[a][c]=1;
			mat[c][a]=1;
		}

		if(i>0){
			a=s1[i-1];
			a=a-'A';
			a=a-('a'-'Z'-1)*(a>30);
			if(mat[a][a]&&mat[a][c]==0&&mat[c][a]==0){
				mat[c][c]--;
				mat[a][c]=1;
				mat[c][a]=1;
			}
		}
		if(i+1<n){
			a=s1[i+1];
			a=a-'A';
			a=a-('a'-'Z'-1)*(a>30);
			if(mat[a][a]&&mat[a][c]==0&&mat[c][a]==0){
				mat[c][c]--;
				mat[a][c]=1;
				mat[c][a]=1;
			}
		}
	}
	for(i=0;i<100;i++){
		if(mat[i][i]){
			ans=ans*mat[i][i]%P;
		}
	}
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
struct mat{
	int a[5][5];
}res,ans,tr,g;
const int mod=1e9+7;
inline mat operator * (const mat &a,const mat &b){
	memset(res.a,0,sizeof(res.a));
	rep(i,0,3)rep(j,0,3)rep(k,0,3)
		res.a[i][j]=(res.a[i][j]+1ll*a.a[i][k]*b.a[k][j])%mod;
	return res;
}
inline mat pow(mat a,int b){
	mat res;memset(res.a,0,sizeof(res.a));
	res.a[0][0]=res.a[1][1]=res.a[2][2]=res.a[3][3]=1;
	for(;b;b>>=1){
		if(b&1)res=res*a;
		a=a*a;
	}return res;
}
int n,m;
int main(){
	read(n);read(m);
	ans.a[0][3]=1;
	tr.a[0][0]=1;
	tr.a[1][0]=1;tr.a[1][1]=1;
	tr.a[2][0]=1;tr.a[2][2]=1;
	tr.a[3][0]=1;tr.a[3][1]=1;tr.a[3][2]=1;tr.a[3][3]=1;
	int last=0;
	rep(i,1,m+1){
		int x=n+1;
		if(i<=m)read(x);
		memset(g.a,0,sizeof(g.a));
		g.a[0][0]=1,g.a[0][3]=1;
		g.a[1][0]=1,g.a[1][1]=1,g.a[1][3]=1;
		g.a[2][0]=1,g.a[2][2]=1,g.a[2][3]=1;
		g.a[3][0]=1,g.a[3][1]=1,g.a[3][2]=1,g.a[3][3]=2;
		g=pow(g,x-last-1);
		ans=ans*g;
		if(i<=m)ans=ans*tr; 
		last=x;
	}
	cout<<ans.a[0][0]<<endl;
	return 0;
}


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

int main() {
    ll n; cin >> n;
    vector<ll> a;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        ll _a; cin >> _a;
        a.push_back(_a);
        sum += _a;
    }
    ll closest = a[0];
    ll subsum = a[0];
    for (int i = 1; i < n-1; i++) {
        subsum += a[i];
        if (abs(closest - sum/2) > abs(subsum - sum/2)) {
            closest = subsum;
        }
    }
    cout << abs(closest * 2 - sum) << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define N 505
#define rep(i,fr,to) for(int i=fr;i<=to;i++)
using namespace std;
char mp[N][N],r[N][N],b[N][N];
int h,w;
int main(){
	scanf("%d%d",&h,&w);
	rep(i,1,h) scanf("%s",mp[i]+1);
	memcpy(r,mp,sizeof(mp));memcpy(b,mp,sizeof(mp));
	rep(i,1,w-1) r[1][i]=b[h][i+1]='#';
	rep(i,1,h-1) r[i+1][1]=b[i][w]='#';
	rep(i,2,h-1)
		rep(j,2,w-1){
			if((j%2==0&&j+j<w+1)||((w-j+1)%2==1&&(w-j+w-j)<w-1)) b[i][j]='#';
			if((j%2==1&&j+j<w+1)||((w-j+1)%2==0&&(w-j+w-j)<w-1)) r[i][j]='#';
		}
	rep(i,1,h) puts(r[i]+1);puts("");
	rep(i,1,h) puts(b[i]+1);
	return 0;
} 

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

int n;

void ss(string s,int j){
    if(s.size()==n){cout<<s<<endl;return;}
    rep(i,j-'a'+2){
        char c='a'+i;
        ss(s+c,max(j,(int)c));
    }
}

int main() {
    cin>>n;
    ss("a",'a');
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int result = 0;
  if (a >= 13) {
    result = b;
  } else if (a >= 6 && a <= 12) {
    result = b / 2;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int md=1000000007;
int f[2010][2010],fac[4000010],inv[4000010],rev[4000010];
int c(int n,int m){return 1ll*fac[n]*rev[m]%md*rev[n-m]%md;}
int main()
{
    int n,k;
    cin>>n>>k;
    if(k==1){puts("1");return 0;}
    f[0][0]=1;
    fac[0]=fac[1]=1,inv[1]=1,rev[0]=rev[1]=1;
    for(int i=2;i<=n*k;i++)
	{
		fac[i]=1ll*fac[i-1]*i%md;
		inv[i]=1ll*(md-md/i)*inv[md%i]%md;
		rev[i]=1ll*rev[i-1]*inv[i]%md;
	}
	for(int i=1;i<=n;i++)for(int j=i;j>=0;j--)
	{
	    f[i][j]=f[i][j+1];
	    if(j)f[i][j]=(f[i][j]+1LL*f[i-1][j-1]*c(i*k-j-1,k-2)%md)%md;
	}
    cout<<1LL*f[n][0]*fac[n]%md<<endl;
    return 0;
}

Measured memory_bytes: 62848
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int ans = 0;
    int total = 0;
    int a[n];
    for (int i =0; i <  n; i++){
        scanf("%d",&a[i]);
        total += a[i];
    }
    for (int i = 0; i < n; i++){
        if (4*m*a[i] >= total) ans++;
    }
    printf("%s",ans>=m?"Yes":"No");
}


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

int main() {
    int num_mochis, diameter;
    vector<int> mochis;

    cin >> num_mochis;
    for(int i = 0; i < num_mochis; i++) {
        cin >> diameter;
        mochis.push_back(diameter);
    }
    sort(mochis.begin(), mochis.end());
    mochis.erase(unique(mochis.begin(), mochis.end()), mochis.end());
    cout << mochis.size() << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a[] = new int[31];
		int w,n,x,y;
		w = in.nextInt();
		for(int i=1;i<=w;i++)
			a[i] = i;
		n = in.nextInt();
		for(int i=0;i<n;i++) {
			String str = in.next();
			String num[] = str.split(",");
			x = Integer.parseInt(num[0]);
			y = Integer.parseInt(num[1]);
			int t = a[x];
			a[x] = a[y];
			a[y] = t;
		}
		for(int i=1;i<=w;i++) {
			System.out.println(a[i]);
		}
		in.close();
	}
}


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

int main()
{
	string cat;
	cin >> cat;
	for (int i = 0; i < 3; i++)
	{
		if (cat[i] == '7')
		{
			cout << "Yes";
			exit(0);
		}
	}
	cout << "No";
	
	return 0;
}



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

max = 0
min = 10000000000000000000

for i in range(N):
    if max < A[i]:
        max = A[i]

for i in range(N):
    if min > A[i]:
        min = A[i]
       
print(max-min)

Measured memory_bytes: 3064
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter


import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())

XY = []
for i in range(N):
	X, Y = list(map(int, input().split()))
	XY.append((X, Y))

towns = [i for i in range(N)]

keiros = list(permutations(towns))

sum = 0

def dist(A, B):
	sum = (A[0] - B[0])**2 + (A[1] - B[1])**2
	sum = sum ** 0.5
	return sum


for keiro in keiros:
	total = 0
	for i in range(N - 1):

		A = XY[keiro[i]]
		B = XY[keiro[i + 1]]
		total += dist(A, B)
	sum += total



def fact(n, mod=1000000007):
	ans = 1
	for i in range(n):
		ans *= i + 1
		if mod != 0 and ans >= mod:
			ans = ans % mod
	return ans

sum /= fact(N)

print(sum)

Measured memory_bytes: 72556
import sys
 
IDX_TBL = {1:[2,3,5,4], 2:[3,1,4,6], 3:[1,2,6,5],4:[1,5,6,2], 5:[1,3,6,4], 6:[2,4,5,3]}
l1=["_"] + raw_input().split(" ")
l2=["_"] + raw_input().split(" ")
if l1[1] in l2:
    idx_list = [i for i,x in enumerate(l2) if x==l1[1]]
    for idx in idx_list:
        nums1 = "".join([l1[i] for i in IDX_TBL[1]])
        nums2 = "".join([l2[i] for i in IDX_TBL[idx]])
        if nums2 in nums1*2:
            print "Yes"
            sys.exit(0)
print "No"

Measured memory_bytes: 6464
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2;
    return 0;
}


Measured memory_bytes: 256