akhauriyash/Code-Regression huggingface dataset:
import Data.List
import qualified Data.ByteString.Char8 as B
main=do
    _<-getLine
    ds<-sort.unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
    _<-getLine
    ts<-sort.unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
    putStrLn $ if f ds ts then "YES" else "NO"
f _ [] = True
f [] _ = False
f (d:dr) ts@(t:tr)
    | d == t = f dr tr
    | d < t  = f dr ts
    | otherwise = False

Measured memory_bytes: 59772
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, next((a).begin()));
#define ll long long int

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(n + 1), y(m + 1);
    cin >> x[0] >> y[0];
    in_arr(int, x, n);
    in_arr(int, y, m);
    int mx = accumulate(x.begin(), x.end(), INT_MIN, [](int a, int b){ return max(a, b); });
    int my = accumulate(y.begin(), y.end(), INT_MAX, [](int a, int b){ return min(a, b); });
    if(mx < my){
        cout << "No War" << endl;
    }else {
        cout << "War" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    unsigned int input1 = 0;
    unsigned int input2[200000] = {};
    scanf("%d", &input1);
    for(int i=0; i<input1; ++i) {
        scanf("%d", &input2[i]);
    }
    unsigned int result = 0;
    unsigned int index = 0;
    unsigned int brokenList[200000] = {};
    for(int i=0; i<input1; ++i) {
        if(input2[i] == index+1) {
            brokenList[index] = input2[i];
            index++; 
        } else {
            result++;
        }
    }
    int tmp = input1-result;
    if(tmp == 0) {
        tmp = 1;
    }
    for(int i=0; i<tmp; ++i) {
        if(brokenList[i] != i+1) {
            result = -1;
        }
    }
    printf("%d\n", result);
    return 0;
}

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

string grid[500];
int posy[26][2],posx[26][2];
int pos[26][2][2];
bool use[26];
int n,m;
int res;

bool cluck(int y,int x,int z){
  int k;
  int cnt[26];
  for(int i=0;i<26;i++)cnt[i] = 0;

  k = 1;
  while(y+k<n && grid[y+k][x] == '.')k++;
  if(y+k<n)cnt[grid[y+k][x]-'A']++;

  k = 1;
  while(x+k<m && grid[y][x+k] == '.')k++;
  if(x+k<m)cnt[grid[y][x+k]-'A']++;

  k = 1;
  while(y-k>=0 && grid[y-k][x] == '.')k++;
  if(y-k>=0)cnt[grid[y-k][x]-'A']++;

  k = 1;
  while(x-k>=0 && grid[y][x-k] == '.')k++;
  if(x-k>=0)cnt[grid[y][x-k]-'A']++;

  if(cnt[z]==2){
    res += 2;
    grid[posy[z][0]][posx[z][0]] ='.';
    grid[posy[z][1]][posx[z][1]] ='.';
    return true; 
  }
  return false;
}

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> grid[i];

  for(int i=0;i<26;i++){
    posy[i][0] = -1;
    posx[i][0] = -1;
    posy[i][1] = -1;
    posx[i][1] = -1;
    use[i] = false;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(grid[i][j] != '.'){
	if(posy[grid[i][j]-'A'][0]<0){
	  posy[grid[i][j]-'A'][0] = i;
	  posx[grid[i][j]-'A'][0] = j;
	  use[grid[i][j]-'A'] = true;
	}else{
	  posy[grid[i][j]-'A'][1] = i;
	  posx[grid[i][j]-'A'][1] = j;
	}
      }
    }
  }

  res = 0;
  while(1){
    bool exit = false;
    for(int i=0;i<26;i++){
      if(use[i]){
	bool f = false;
	if(posy[i][0] == posy[i][1]){
	  int s = min(posx[i][0],posx[i][1]),g = max(posx[i][0],posx[i][1]);
	  for(int j=s+1;j<g;j++){
	    if(grid[posy[i][0]][j]=='.')f |= cluck(posy[i][0],j,i);
	  }
	}else if(posx[i][0] == posx[i][1]){
	  int s = min(posy[i][0],posy[i][1]),g = max(posy[i][0],posy[i][1]);
	  for(int j=s+1;j<g;j++){
	    if(grid[j][posx[i][0]]=='.')f |= cluck(j,posx[i][0],i);
	  }
	}else{
	  if(grid[posy[i][0]][posx[i][1]] == '.')f |= cluck(posy[i][0],posx[i][1],i);
	  if(grid[posy[i][1]][posx[i][0]] == '.')f |= cluck(posy[i][1],posx[i][0],i);
	}
	if(f)use[i] = false;
	exit |= f;
      }
    }
    if(!exit)break;
  }

  cout << res << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  string in;
  cin >> in;
  if(in == "abc" ||
     in == "acb" ||
     in == "bac" ||
     in == "bca" ||
     in == "cab" ||
     in == "cba")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        if(500 * k >= x ) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35628
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --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;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++){
        ll now = (n-1)/i;
        ans+= now;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

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

using namespace std;

int main(){
	string a, b;
	cin >> a;
		cin >> b;
		//cout << a << " " << b << endl;

		if(a.length() < b.length()) {
    	cout << "LESS" << endl;
  	}else if(a.length() > b.length()) {
    	cout << "GREATER" << endl;
		}else{
			int len = a.length();
			bool flag = true;
			for(int i = 0; i < len; i++){
				if(a[i] > b[i]){
					cout << "GREATER" << endl;
					flag = false;
					break;
				}else if(b[i] > a[i]){
					cout << "LESS" << endl;
					flag = false;
					break;
				}
			}
			if(flag) cout << "EQUAL" << endl;
		}

//	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int cnt1[n] = {0}, cnt2[n] = {0};
    (s[0] == 'W') ? cnt1[0] = 1 : cnt2[0] = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i] == 'W')
        {
            cnt1[i] = cnt1[i-1] + 1;
            cnt2[i] = cnt2[i-1];
        }
        else
        {
            cnt2[i] = cnt2[i-1] + 1;
            cnt1[i] = cnt1[i-1];
        }

    }
    int minn = min(cnt2[n-1]-cnt2[0], cnt1[n-1]);
    for (int i = 1; i < n-1; i++)
    {
        if (minn > cnt2[n-1]-cnt2[i] + cnt1[i-1])
            minn = cnt2[n-1]-cnt2[i] + cnt1[i-1];
    }
    cout << minn << endl;
    return 0;
}


Measured memory_bytes: 3076
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
 
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 10e16
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,e,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n>>a>>b>>c>>d>>e;
    //n=a+b+c+d+e;
    mini=min(mini,a);
    mini=min(mini,b);
    mini=min(mini,c);
    mini=min(mini,d);
    mini=min(mini,e);
    if(n<=mini){
        cout<<5<<endl;
    }else{
    sum=n/mini;
    if(n%mini!=0) sum++;
    sum+=4;
    cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
  #define N 100005
  using namespace std;
  int arr[N];

  int main() {
    int n, k;cin >> n >> k;
    int bir;
    for(int i = 0; i < n;i++) {
      cin >> arr[i];
      if(arr[i] == 1) bir = i;
    }
    int sag = n-bir-1, sol = bir;
    cout << ceil((double)sag/(k-1) + (double)sol/(k-1)) <<endl;
  }


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5000*5000+5;
ll n,a[5],b[5],dpA[N],dpB[N];

int main()
{
	cin>>n;
	cin>>a[0]>>a[1]>>a[2];
	cin>>b[0]>>b[1]>>b[2];
	for(ll i=1;i<N;i++)
	{
		dpA[i]=i;
		for(int j=0;j<3;j++)
			if(i>=a[j])
				dpA[i]=max(dpA[i],dpA[i-a[j]]+b[j]);
	}


	for(ll i=1;i<N;i++)
	{
		dpB[i]=i;
		for(int j=0;j<3;j++)
			if(i>=b[j])
				dpB[i]=max(dpB[i],dpB[i-b[j]]+a[j]);
	}
	cout<<dpB[dpA[n]]<<endl;
	return 0;
} 

Measured memory_bytes: 390912
#include <iostream>

using namespace std;

void Search(int n) {
	if (n == 0)
		return;
	int a = n % 2;
	if (a == 0) {
		Search(n / -2);
		printf("0");
	}
	else {
		Search((n - 1) / -2);
		printf("1");
	}
	return;
}

int main(void) {
	int n;
	cin >> n;
	if (n == 0)
		printf("0\n");
	else
		Search(n);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;
constexpr ll mod = inf;

template <long long MOD = 1000000007LL>
long long powmod(long long x, long long n) {
    long long ret = 1LL;
    long long t = x % MOD;
    while (n > 0) {
        if (n & 1LL) {
            ret *= t;
            ret %= MOD;
        }
        t *= t;
        t %= MOD;
        n >>= 1;
    }
    return ret;
}

ll nck(ll n, ll k) {
    ll fact_k = 1;
    for (ll i = 1; i <= k; ++i)
        fact_k = fact_k * i % mod;
    ll npk = 1;
    for (ll i = n; i >= n - k + 1; --i)
        npk = npk * i % mod;
    return npk * powmod(fact_k, mod - 2LL) % mod;
}

int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll ans = powmod(2LL, n);
    ans -= nck(n, a);
    ans += mod;
    ans %= mod;
    ans -= nck(n, b);
    ans += mod;
    ans %= mod;
    cout << (ans - 1 + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n,sum=0;
	cin >> n;
	vector<int> v(n);
	r(i,n) {
      cin >>v.at(i);
      sum+=v.at(i);
    }
  sort(v.begin(),v.end());
  if(v.at(n-1)<(sum-v.at(n-1))) cout << "Yes" << endl;
     else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#include <complex>
typedef complex<double> P;
typedef vector<double> vd;
typedef vector<vd> vvd;

#define EQ(x,y) (abs((x)-(y))<EPS)
#define LT(x,y) ((x)-(y)<=-EPS)

double dot(P a, P b) {
	return a.real()*b.real()+a.imag()*b.imag();
}

double angle_ls(P a, P b, P c) {
	P v1 = b-a, v2 = c-b;
	return acos(dot(v1, v2)/(abs(v1)*abs(v2)));
}

double to_radian(double degree) {
	return degree*PI/180;
}

double to_degree(double radian) {
	return radian*180/PI;
}

int main() {
	int n;
	double r, t;
	cin >> n >> r >> t;

	vector<P> pts(n);
	REP(i, n) {
		double x, y;
		cin >> x >> y;
		pts[i] = P(x, y);
	}

	vector<vvd> dist(n, vvd(n, vd(n, INF)));
	REP(i, n) {
		REP(j, n) {
			if(i == j) {
				continue;
			}
			REP(k, n) {
				if(i == k || j == k) {
					continue;
				}
				double angle = to_degree(angle_ls(pts[i], pts[j], pts[k]));
				if(LT(angle, t)) {
					dist[i][j][k] = abs(pts[k]-pts[j]);
				}
			}
		}
	}

	vector<vvd> dp(10000+1, vvd(n, vd(n, INF)));
	int ans = 0;
	FOR(i, 1, n-1) {
		double d = abs(pts[i]-pts[0]);
		if(LT(d, r)) {
			dp[1][0][i] = d;
			ans = 1;
		}
	}

	FOR(c, 2, 10000) {
		bool updated = false;
		REP(i, n) {
			REP(j, n) {
				double d = dp[c-1][i][j];
				if(EQ(d, INF)) {
					continue;
				}

				REP(k, n) {
					double nd = d + dist[i][j][k];
					if(LT(nd, r) && LT(nd, dp[c][j][k])) {
						ans = c;
						dp[c][j][k] = nd;
						updated = true;
					}
				}
			}
		}

		if(!updated) {
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 40604
def find(M,D):
    count=0
    for m in range(1,M+1):
        for d in range(1,D+1):
            if len(str(d))==2:
                d0=int(str(d)[0])
                d1=int(str(d)[1])
                if d0>1 and d1>1:
                    if d0*d1==m:
                        count+=1
    return count
M,D=list(map(int,input().strip().split(' ')))
print(find(M,D))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
using namespace std;

int solve(int n, int k, vector<int> &c, vector<int> &dp)
{
    if (n == 1) return 0;
    if (dp[n] != -1) return dp[n];
    int best = INF;
    for(int i=1;i<=k;i++){
        if(n-i>0) best = min(best, solve(n-i,k,c,dp)+abs(c[n]-c[n-i]));
    }
    return dp[n] = best;
}

int main()
{
    int n,k;
    scanf("%d", &n);
    scanf("%d", &k);
    vector<int> c(n + 1);
    vector<int> dp(n + 1, -1);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &c[i]);
    }
    //재귀로 풀어봅시다.
    //solve 는 n일 때 최소가 되는 값을 반환하는 함수라고 합시다.
    dp[0] = INF;
    printf("%d", solve(n, k, c, dp));
    return 0;
}


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


void solve(){
  string s;cin>>s;
  unsigned long long int val=0;
  for(unsigned long long int i=0;i<s.length();i++){
      val += (int)(s[i]-'0');
  }   
  if(val%9==0)cout<<"Yes";
  else cout<<"No";
}


int main(){
    //ll tt;cin>>tt;
    //while(tt--){
        solve();
    //}
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  int n,T;
  cin >> n >> T;
  vector<int> t(n);
  ll end = 0;
  ll ans = 0;
  rep(i, n)
  {
    cin >> t[i];
    if(end < t[i]){
      end = T + t[i];
      ans += T;
    }else{
      ans += T + t[i] - end;
      end = t[i] + T;
    }
  }
  cout << ans << endl;
}

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

#define ll long long

using namespace std;

string s;

ll solve(int i, int add, string a)
{
	if(i >= s.size())
	{
		string na = "";
		ll tot = 0;
		if(add)
		{
		//	cout << a << endl;
			for(int j = 0; j < a.size(); j++)
			{
				if(a[j] == '+')
				{
					tot += (na!=""?stoll(na):0);
					na = "";
				}
				else
				{
					na += a[j];
					if(j==a.size()-1)
					{
						tot += (na!=""?stoll(na):0);
					}
				}
			}
		}
		return tot;
	}
	if(add)
	{
		string na = a;
		na += "+";
		na += s[i];
		return solve(i+1, 0, na) + solve(i+1, 1, na);
	}
	else
	{
		return solve(i+1,1,a+s[i]) + solve(i+1,0,a+s[i]);
	}
}

int main()
{
	cin >> s;
	ll total = solve(0,0,"");
	cout << total << endl;
}

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())

n = f//(100*a)
m = f//(100*b)
p = f//c
q = f//d

mx = 0
for k in range(p+1):
    for l in range(q+1):
        for i in range(n+1):
            for j in range(m+1):
                if i == 0 and j == 0:
                    continue
                s = 100*a*i+100*b*j
                t = c*k+d*l
                u = 100*t/s
                if s + t> f:
                    continue
                if u > e:
                    continue
                if mx <= u:
                    mx = u
                    ans1, ans2 = s+t, t
                    if mx == e:
                        print(ans1, ans2)
                        exit()
print(ans1, ans2)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int mod=998244353;
int main(){
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>> inter(k);
    for(int i=0;i<k;i++)
    {
        cin>>inter[i].first>>inter[i].second;
    }
    sort(inter.begin(),inter.end());
    vector<pair<int,int>> rang;
    int mi=inter[0].first;
    int mx=inter[0].second;
    for(int i=1;i<inter.size();i++)
    {
        if(inter[i].first<=mx)
        {
            mx=max(mx,inter[i].second);
        }
        else 
        {
            rang.pb({mi,mx});
            mi=inter[i].first;
            mx=inter[i].second;
        }
    }
    rang.pb({mi,mx});
   // for(auto it : rang) cout<<it.first<<" "<<it.second<<"\n";
    vector<ll> dp(n+1,LLONG_MAX);
    vector<ll> suff(n+2);
    dp[n]=1;
    suff[n]=1;

    for(int i=n-1;i>=1;i--)
    {
        ll calc=0;
        for(auto r : rang)
        {
            if(i+r.second<=n)
            {
                calc=(calc-suff[i+r.second+1]+suff[i+r.first]+mod)%mod;
            }
            else
            {
                if(i+r.first<=n)
                {
                    calc=(calc+suff[i+r.first]+mod)%mod;
                    break;
                }
                else break;
            }
            
        }
        dp[i]=calc;
        suff[i]=suff[i+1]+dp[i];
    }
    cout<<dp[1]<<"\n";



}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
 
int grp(int x) {
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) return 1;
	if (x == 4 || x == 6 || x == 9 || x == 11) return 2;
	return 3;
}
 
int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	if (grp(x) == grp(y)) puts("Yes");
	else puts("No");
}

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

int main(){
	string s,t;
	int c=0;
	cin>>s>>t;
	for(int i=0;i<3;i++){
		if(s[i]==t[i]){
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long MOD = 1000000007;

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

	int r;
	cin >> r;
	cout << r * r << "\n";

	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int n;
ll a[333][333];
int fl[333][333];

int main() {
   cin >> n;
   rep (i, n) {
      rep (j, n) {
         cin >> a[i][j];
      }
   }

   rep (k, n) {
      rep (i, n) {
         rep (j, n) {
            if (a[i][k] + a[k][j] < a[i][j]) {
               cout << -1 << endl;
               return 0;
            } else if (k != i && k != j && a[i][k] + a[k][j] == a[i][j]) {
               fl[i][j] = 1;
            }
         }
      }
   }

   ll ans = 0;
   rep (i, n) {
      repp (j, i+1, n) {
         if (!fl[i][j]) ans += a[i][j];
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
  string s;
  cin>>s;
  int ans=0;
  if(s=="SUN")ans=7;
  if(s=="SAT")ans=1;
  if(s=="MON")ans=6;
  if(s=="TUE")ans=5;
  if(s=="WED")ans=4;
  if(s=="THU")ans=3;
  if(s=="FRI")ans=2;
  cout<< ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long x = input.nextLong();
		long y = input.nextLong();
		int count = 0;
		while (x <= y) {
			x *= 2;
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll k, a, b;
  cin >> k >> a >> b;

  int ok = 0;
  for (int i = a; i < b + 1; i++){
    if (i % k == 0)
      ok = 1;
  }

  if (ok)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  
    
    

  return 0;
}


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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define x first
#define y second
#define pb push_back

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

const int N = 2e6 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

int n;
int a[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    forn(i, 1, n)
        cin >> a[i];

    int ans = 0;
    int cnt = 0;
    forn(i, 1, n) {
        if (a[i] != a[i - 1]) {
            ans += cnt / 2;
            cnt = 0;
        }
        ++cnt;
    }
    cout << ans + cnt / 2 << "\n";

    return 0;
}


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

int main() {
  int N;
  int A;
  int n;
  cin >> N;
  A = 0;
  n = N;
  
  for (int i = 0; i < 9; i++) {
    if (n >= 10) {
      A += n % 10;
      n = n / 10;
    }
    else {
      A += n;
      break;
    }
  }
  
  if (N % A == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    int h[N+1];
    h[0]=0;
    rep(i,N){
        cin >> h[i+1];
    }
    int cnt=0;
    rep(i,101){
        rep(i,N){
            if(h[i]==0 && h[i+1]>0)cnt++;
        }
        rep(i,N+1){
            if(h[i]>0)h[i]--;
        }
    }
    cout << cnt;


}

/*



 */



Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] d) {
    long sum;
    foreach (i; 0 .. N) foreach (j; i + 1 .. N) {
        sum += d[i] * d[j];
    }
    return sum;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] d = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        d[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, d);
    else
        solve(N, d).writeln;
}


Measured memory_bytes: 256
import sys
x = int(raw_input())
# a = [int(raw_input()) for i in xrange(n)]
# a,b,c,d = map(int, raw_input().split())

p = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def isPowerOfTwo(n):
    return (n > 0) and (n & (n - 1) == 0)

# s = raw_input()
# k = int(raw_input())


# print "".join(["a","b"])

# print "Yes" if 3 > 0 else "No"
if x < 4:
    print 1
    sys.exit()

X = x

while x > 1:
    n = x

    if isPowerOfTwo(x) == True:
        print x
        sys.exit()
    if x == 2 or x in p:
        x-=1
        continue
    for i in xrange(3,X):
        n = x
        c = 0
        while True:
            if n % i != 0:
                break
            n /= i
            c += 1
            if n == 1 and c > 1:
                print x
                sys.exit()
    x-=1
print 1

Measured memory_bytes: 2744
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

ll a,b,k;
int m=0;

int main()
{
    cin>>a>>b>>k;
    for (int i=max(a,b); i>=1; --i)
    {
        if ((a%i==0) && (b%i==0))
        {
            m++;
        if (m==k)
            cout<<i<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char c[10000];
int main()
{	scanf("%s",c+1); int n=strlen(c+1),k; cin>>k;
	for(rint i=1;i<=n;i+=k) printf("%c",c[i]);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <sstream>
#define ull unsigned long long
#define ll long long
#define INF 1000000007
using namespace std;

int sum(int n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n/=10;
    }
    return sum;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,ans=0;
    cin >> n >> a >> b;
    for(int i=0;i<=n;i++){
        int d = sum(i);
        if(d<=b && d>=a){
            ans+=i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var DN = input.split(' ');
    var D = Number(DN[0]);
    var N = Number(DN[1]);

    if (D === 0) {
        if (N === 100) console.log(101);
        else console.log(N);
    }
    else if (D === 1) {
        if (N === 100) console.log(10100);
        else console.log(N * 100);
    }
    else {
        if (N === 100) console.log(1010000);
        else console.log(N * 10000);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
program prob4
    implicit none
    integer(8) :: a,b,c
    read(*,*) a,b,c
    if(mod(a,2) == 0 .or. mod(b,2) == 0 .or. mod(c,2) == 0) then
        write(*,'(a)') '0'
        stop
    end if
    write(*,'(i19)')  min(a*b, b*c, c*a)

    stop
contains
end program prob4

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct RussianDoll
{	int h, r; RussianDoll(int h, int r) : h(h), r(r) { }};

bool operator < (RussianDoll left, RussianDoll right)
{	return left.h < right.h && left.r < right.r;	}

struct Edge
{	int from, to, cost;	Edge(int from, int to, int cost) : from(from), to(to), cost(cost) { } };

void input(vector<RussianDoll>& v, int n)
{
	rep(i, n)
	{
		int h, r;
		cin >> h >> r;
		v.push_back(RussianDoll(h, r));
	}
}

int Bellmanford(int n, const vector<Edge>& v)
{
	vint d(n, 0);
	
	bool update = true;
	while(update)
	{
		update = false;
		rep(i, v.size())
		{
			if(d[v[i].from] + v[i].cost < d[v[i].to])
			{
				d[v[i].to] = d[v[i].from] + v[i].cost;
				update = true;
			}
		}
	}
	
	return d[n - 1];
}

int main()
{
    int n;
	while(cin >> n && n)
	{
		vector<RussianDoll> v;
		vector<Edge> edges;
		
		input(v, n);
		
		cin >> n;
		input(v, n);
		
		n = v.size();
		
		rep(i, n) edges.push_back(Edge(0, i + 1, -1)), edges.push_back(Edge(i + 1, n + 1, 0));
		rep(i, n) rep(j, n) if(v[i] < v[j]) edges.push_back(Edge(i + 1, j + 1, -1));
			
		cout << -Bellmanford(n + 2, edges) << endl;
	}
}

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

using namespace std;

int main() {
	int num;
	string s,t;
	while (1) {
		cin >> s >> num;
		if (s[0] == '-')break;
		int a;
		for (int i = 0;i < num;i++) {
			cin >> a;
			t = s.substr(a, s.size() - a) + s.substr(0, a);
			s = t;
		}
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>
#define N 2000000
#define M 99
int sum[N];
int l,r;

int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		char num[M];
		scanf("%s",num);
		if(num[0]=='i')scanf("%d",sum+r++);
		else if(num[6]==0){
			int t;
			scanf("%d",&t);
			for(int xu=r-1;xu>=l;xu--)if(sum[xu]==t){
				sum[xu]=-1;
				break;
			}
		}else if(num[6]=='F')while(sum[--r]==-1);
		else while(sum[l++]==-1);	
	}
	int f=0;
	for(int i=r-1;i>=l;i--)if(sum[i]!=-1)printf(f++?" %d":"%d",sum[i]);
	puts("");
}



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

int main(){
    int n,i,j,d[100],t,x[100];
    char s[100][100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %d",s[i],&d[i]);
        for(j=i;j>0;j--){
            t=strcmp(s[i],s[x[j-1]]);
            if(t<0 || (t==0 && d[i]>d[x[j-1]])) x[j] = x[j-1];
            else break;
        }
        x[j]=i;
    }
    for(i=0;i<n;i++){
        printf("%d\n",x[i]+1);
    }
    return 0;
}

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

typedef long long ll;

ll gcd( ll x, ll y );
ll lcm( ll x, ll y );

int main()
{
    int x, y;
    scanf("%d %d", &x, &y );

    printf("%d %d\n", x * y, 2 * ( x + y ) );

    return 0;
}

ll gcd( ll x, ll y )
{
    if ( y == 0 ) return x;
    return gcd( y, x % y );
}

ll lcm( ll x, ll y )
{
    return x / gcd( x, y ) * y;
}




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

int main() {
  ll A,B,C,X,Y;
  cin >> A>>B>>C>>X>>Y;
  
  ll ans;
  if (A+B<=2*C) {
    ans=A*X+B*Y;
  }
  else {
    if (X>=Y) {
      if (A>2*C) {
        ans = 2*X*C;
      }
      else {
        ans = 2*C*Y+A*(X-Y);
      }
    }
    else {
      if (B>2*C) {
        ans = 2*Y*C;
      }
      else {
        ans = 2*C*X+B*(Y-X);
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
lsa = [list(map(int, input().split())) for i in range(h)]
lsb = [list(map(int, input().split())) for i in range(h)]
ls = [[abs(lsa[i][j] - lsb[i][j]) for j in range(w)] for i in range(h)]
bias = 80*80*80

dp = [[0 for _ in range(w)] for _ in range(h)]

dp[0][0] = 1 << ls[0][0]+bias

for i in range(h):
    for j in range(w):

        if j != 0:  
            dp[i][j] |= dp[i][j-1] << ls[i][j]
            dp[i][j] |= dp[i][j-1] >> ls[i][j]

        if i != 0:
            dp[i][j] |= dp[i-1][j] << ls[i][j]
            dp[i][j] |= dp[i-1][j] >> ls[i][j]

ans = dp[h-1][w-1]
idx = 0
while(1):
    if 1 << (bias+idx) & ans or 1 << (bias-idx) & ans:
        break
    idx += 1
print(idx)

Measured memory_bytes: 451464
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size(),ans=0;
    REP(i,n){
        if(s[i]=='A'){
            ans=i;
            break;
        }
    }
    for(int j=n;j>=0;j--){
        if(s[j]=='Z'){
            ans=j-ans;
            break;
        }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 640
import bisect

n = int(input())
s = list(input())
q = int(input())
l = [[] for i in range(26)]
for i in range(n):
    l[ord(s[i])-ord("a")].append(i)


for i in range(q):
    x,y,z = input().split()
    if int(x) == 1:
        if s[int(y)-1] == z:
            continue
        index = bisect.bisect_left(l[ord(s[int(y)-1])-ord("a")],int(y)-1)
        l[ord(s[int(y)-1])-ord("a")].pop(index)
        index = bisect.bisect_left(l[ord(z)-ord("a")],int(y)-1)
        l[ord(z)-ord("a")].insert(index,int(y)-1)
        s[int(y)-1] = z
    if int(x) == 2:
        count = 0
        for j in l:
            index = bisect.bisect_left(j,int(y)-1)
            if index < len(j) and j[index] < int(z):
                count += 1
        print(count)





Measured memory_bytes: 28808
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int N, Y; cin >> N >> Y;
    
    REP(x, 0, N) {
        REP(y, 0, N) {
            int z=N-(x+y);
            if (z >= 0 && x*10000 + y*5000 + z*1000 == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl; 
    return 0;
}

Measured memory_bytes: 256
program sample
    implicit none
    real(8)::x,y,z
    integer(8) :: a,b,c,i,j,m,n,k,a1,b1,c1
    
    
  
    read(*,*) a,b,c,k
    if (mod(k,2)==0)then
        write(*,*) a-b
    else 
        write(*,*) b-a
    end if
    stop
end program sample
  



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int d = sc.nextInt();
		
		int a = 0;
		
		do {
			a++;
			n--;
			
		} while (a * 2 * d < n);
		
		System.out.println(a);
		
		sc.close();
		
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; ll k;
    cin >> n >> k;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll x = 0;
    bool leading_zero = true;
    bool less = false;
    for (int i = 39; i >= 0; --i) {
        if (k>>i&1) leading_zero = false;
        if (!leading_zero) {
            if (less || k>>i&1) {
                int cnt1 = 0;
                rep(j, n) if (a[j]>>i&1) cnt1++;
                if (cnt1 >= (n+1)/2) {
                    less = true;
                } else {
                    x |= 1LL<<i;
                }
            }
        }
    }
    ll ans = 0;
    rep(i, n) ans += x ^ a[i];
    cout << ans << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B,C;
	cin >> A >> B >> C;
	int a = min(A,B+C);
	cout << C - (a-B) << endl;
}

Measured memory_bytes: 256
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define endl '\n'


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
		int a, p;
        in >> a >> p;
        p += 3*a;
        out << p/2 << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




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

int gcd(int a, int b) {
    int tmp;
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    return (a % b == 0 ? b : gcd(b, a % b));
}

int main() {
    int n, x, xi;
    cin >> n >> x;

    cin >> xi;
    int d = abs(x - xi);
    for (int i = 1; i < n; i++) {
        cin >> xi;
        d = gcd(d, abs(x - xi));
    }

    cout << d << endl;
}

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

class Solve {
private:
	using vd = std::vector<double>;
	using vvd = std::vector<vd>;

	double square(double x) { return x * x; }

public:
	bool is_last_query{};
	Solve()
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
		{
			is_last_query = true;
			return;
		}
		vvd edge(n, vd(n));
		std::vector<double> x(n), y(n), z(n), r(n);
		for (int i{}; i < n; i++)
			scanf("%lf%lf%lf%lf", &x[i], &y[i], &z[i], &r[i]);
		for (int i{}; i < n; i++)
		{
			for (int j{}; j < n; j++)
			{
				double distance{sqrt(square(x[i] - x[j]) + square(y[i] - y[j]) + square(z[i] - z[j]))};
				edge[i][j] = std::max(0.0, distance - r[i] - r[j]);
			}
		}

		std::vector<bool> used(n);
		used[0] = true;
		std::vector<double> distance(n);
		distance = edge[0];
		double ans{};
		for (int size{1}; size < n; size++)
		{
			int min_i{};
			double min{1e9};
			for (int i{}; i < n; i++)
				if (!used[i] && distance[i] < min)
				{
					min_i = i;
					min = distance[i];
				}

			ans += min;
			used[min_i] = true;
			for (int i{}; i < n; i++)
				distance[i] = std::min(distance[i], edge[min_i][i]);
		}
		printf("%.3lf\n", ans);
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


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

int main()
{
  string s;
  cin>>s;
  long long k,i=0;
  cin>>k;
  
  while(k)
  {
    if(s[i]=='a'){
      i++;
      if(i==s.size())break;
      continue;}
    if(('z'-s[i]+1LL) <= k)
    {
      	k-=('z'-s[i]+1LL);
        //cout << 'z'-s[i] << endl;
      	s[i]='a';
    }
    i++;
    if(i==s.size())break;
  }

  if(k>0LL)
  {
    k%=26LL;
    s[s.size()-1]+=k;
  }
  
  cout << s << endl;

  
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	int N, Q;
	string S;
	cin >> N >> Q >> S;

	vector<int> ruiseki(100010);
	REP(i,1,S.size()) {
		if (S[i-1] == 'A' and S[i] == 'C') {
			ruiseki[i+1] = ruiseki[i] + 1;
		}
		else {
			ruiseki[i+1] = ruiseki[i];
		}
	}

	rep(i, Q) {
		int l, r;
		cin >> l >> r;
 
		cout << ruiseki[r] - ruiseki[l] << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#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>;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
const ll INF = 1LL << 60;

int main()
{

    int n;
    cin >> n;
    int p[n];
    rep(i,n){
        cin >> p[i];
    }

    int ans = 0;
    rep(i, n - 2){
        if ((p[i] > p[i+1])&&(p[i+1] > p[i+2]))
        {
                ans += 1;
        }
        if ((p[i] < p[i + 1]) && (p[i + 1] < p[i + 2]))
        {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define INF 1000000001
#define fi first
#define se second
using namespace std;
const int N=2e3+100;
vector<int> adj[N]={};
int cnt=0;
void dfs(int u,int p=-1,int level=0){
  if(level<0) return ;
  cnt++;
  for(auto v: adj[u]){
   if(v!=p) dfs(v,u,level-1);
}
}
int main(){
  int n,k;
  cin>>n>>k;
  vector<pair<int,int> > edge;
  for(int i=0;i<n-1;i++){
   int a,b;
   cin>>a>>b;
   adj[a].push_back(b);
   adj[b].push_back(a);
   edge.push_back(make_pair(a,b));
}
   int min1=INF;
   if(k%2==0){
    for(int i=0;i<n;i++){
     dfs(i,-1,k/2);
     min1=min(min1,n-cnt);
     cnt=0;
}
}
   else {
   for(auto p: edge){
    dfs(p.fi,p.se,(k-1)/2);
    int a=cnt;
    cnt=0;
    dfs(p.se,p.fi,(k-1)/2);
    a+=cnt;
    min1=min(min1,n-a);
    cnt=0;
}
}
   cout<<min1<<endl;
   return 0;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     ll x;
     cin >> x;
     ll ans = (x/11)*2;
     if(x%11 > 6)ans+=2;
     else if(x%11>=1) ans+=1;
     cout << ans;
  }


  int main(){
    IOS
       solve();
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
#include <queue>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int H, W;
  cin >> H >> W;
  string A[H];
  for (int i = 0; i < H; ++i) {
    cin >> A[i];
  }
  int B[H][W];
  queue<int> q;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (A[i][j] == '#') {
        B[i][j] = 0;
        q.push(i*W+j);
      }else {
        B[i][j] = -1;
      }
    }
  }
  int t,h,w;
  while (!q.empty()) {
    t = q.front();
    q.pop();
    h = t/W;
    w = t - h*W;
    if (h > 0){
      if (B[h-1][w] == -1){
        B[h-1][w] = B[h][w]+1;
        q.push((h-1)*W+w);
      }
    }
    if (h < H -1){
      if (B[h+1][w] == -1){
        B[h+1][w] = B[h][w]+1;
        q.push((h+1)*W+w);
      }
    }
    if (w > 0){
      if (B[h][w-1] == -1){
        B[h][w-1] = B[h][w]+1;
        q.push(h*W+w-1);
      }
    }
    if (w < W -1){
      if (B[h][w+1] == -1){
        B[h][w+1] = B[h][w]+1;
        q.push(h*W+w+1);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (B[i][j] > ans) {
        ans = B[i][j];
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 9344
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = a-b;
            if(c<0){
                System.out.println("a < b");
            }else if(c>0){
                System.out.println("a > b");
            }else{
                System.out.println("a == b");
            }
        }
    }
}


Measured memory_bytes: 26368
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
nextcity = [[] for _ in range(N)]
sgn = [0 for _ in range(N)]
while M:
	M -= 1
	A, B = map(int, input().split())
	A -= 1
	B -= 1
	nextcity[A].append(B)
	nextcity[B].append(A)

def bfs(cnt, lis):
	nextvisit = []
	for j in lis:
		for item in nextcity[j]:
			if sgn[item] == 0:
				nextvisit.append(item)
				sgn[item] = cnt
	if nextvisit:
		bfs(cnt, nextvisit)
		return None
	else:
		return None
cnt = 0
for k in range(N):
	if sgn[k] == 0:
		cnt += 1
		sgn[k] = cnt
		bfs(cnt, [k])
print(cnt -1)


Measured memory_bytes: 27316
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 84120