akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = str(input())
b = str(input())
ans = 0
for i in range(n):
    if a[i] == b[0]:
        if a[i:]==b[:(n-i)]:
            ans = len(a[i:])
            break
    if i == n-1 and a[i] == b[0]:
        ans = 1
print(2*n - ans)

Measured memory_bytes: 3060
(n,m),*l=[list(map(int,s.split()))for s in open(0)];d=[0]*2+[9e99]*n
for i in range(n*2):
 for a,b,c in l:d[b]=min(d[b],d[a]-c)
 if i==n:x=d[n]
print([-x,'inf'][d[n]!=x])

Measured memory_bytes: 44124
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, T;
    cin >> N >> T;
    ll t1, t2, res = T;
    cin >> t1;
    FOR(i, 1, N, 1) {
        cin >> t2;
        res += min(T, t2 - t1);
        t1 = t2;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;
    int t=s.size();
    if(s.at(t-1)=='3') cout<<"bon"<<endl;
    else if(s.at(t-1)=='0'||s.at(t-1)=='1'||s.at(t-1)=='6'||s.at(t-1)=='8') cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
ll dx[4]={0,0,1,-1};
ll dy[4]={-1,1,0,0};


void solve()
{
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t<d)
        cout<<"No";
    else
        cout<<"Yes";
    return;
}

int main()
{
	FAST;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
        solve();
	return 0;
}

Measured memory_bytes: 3628
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N; cin >> N;
    vector<double> A(N); rep(i, N)cin >> A[i];
    double sum = 0;
    for (auto x : A)sum += x;
    sum /= N;
    double MAX = INF;
    int NUM;
    for (int i = N - 1; i >= 0; i--) {
        if (MAX >= abs(sum - A[i])) {
            MAX = abs(sum - A[i]);
            NUM = i;
        }
    }
    cout << NUM << endl;
}






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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s,ans;
    cin >> s;
    for(auto the:s){
        switch (the) {
            case '0': ans.append("0"); break;
            case '1': ans.append("1"); break;
            case 'B': if(ans.length())ans.pop_back(); break;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
n=gets.to_i
1.upto(3500) do |a|
  1.upto(3500) do |b|
    bs=n*a*b
    bb=4*a*b-n*(a+b)
    if bb>0&&bs%bb==0
      c=bs/bb
      puts [a,b,c].join(" ")
      exit
    end
  end
end



Measured memory_bytes: 14348
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n)
  {
    cin >> h[i];
  }
  reverse(h.begin(), h.end());
  rep(i, n-1)
  {
    int d = h[i+1] - h[i];
    if(d <= 0)
      continue;
    if(d > 1)
    {
      cout << "No" << endl;
      return 0;
    }
    if(d == 1)
      h[i+1]--;
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
    int x;
    cin >> x;
    int ans = lcm(360, x)/x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <cstring>

#define rep(a, b, c) for (int a = b; a < (c); a++)
#define repe(a, b, c) for (int a = b; a <= (c); a++)
#define repr(a, b, c) for (int a = b; a > (c); a--)
#define repre(a, b, c) for (int a = b; a >= (c); a--)

using namespace std;

int main() {
    string s;
    cin >> s;
    bool c = false;
    rep(i, 0, s.size()) {
        if (!c) {
            c = s[i] == 'C';
        } else {
            if (s[i] == 'F') {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <math.h> 
using namespace std;

typedef long long LL;

int main(){
    LL a,b;
    scanf("%lld%lld",&a,&b);
    LL c=a,ans=0;
    while(c<=b){
        ans++;
        c*=2;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t X, Y;

	scanf("%zu %zu", &X, &Y);

	printf("%zu\n", X + Y/2);

	return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> c(4,0);
    rep(i,n){
        string s; cin >> s;
        if(s[0] == 'A') c[0]++;
        else if(s[0] == 'W') c[1]++;
        else if(s[0] == 'T') c[2]++;
        else if(s[0] == 'R') c[3]++;
    }
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
    return 0;
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int32_t main()
{
	IOS;
	int n, W;
	int w[N], v[N];
	vector<int> dp(N, 0);
	vector<int> prevDp(N, 0);
	cin >> n >> W;
	rep(i, 0, n)
	{
		cin >> w[i] >> v[i];
	}
	rep(i, 0, n)
	{
		rep(j, w[i], W + 1)
		{
			dp[j] = max(prevDp[j], prevDp[j - w[i]] + v[i]);
		}
		prevDp = dp;
	}
	cout << dp[W] << endl;
	return 0;
}


Measured memory_bytes: 7040
def get_values():
    return [int(a) for a in input().split()]

N, M, X = get_values()
As = get_values()

left_cost = 0
for a in As:
    if a > X:
        break
    left_cost += 1
right_cost = len(As) - left_cost
print(min(left_cost, right_cost))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

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

    int n;
    cin>>n;
    string s;
    set<string> se;
    for(int i = 0; i<n; i++){
        cin>>s;
        se.insert(s);
    }
    cout<<(int)se.size();
}

Measured memory_bytes: 19068
calc :: [String] -> (Int, [String])
calc (num:[]) = (read num,[])
calc (d:ds)
  | d == "+" = calc' (+)
  | d == "-" = calc' (-)
  | d == "*" = calc' (*)
  | otherwise = (read d, ds)
    where
      calc' f = (f d2 d1, ds'')
      (d1, ds') = calc ds
      (d2, ds'') = calc ds'

main :: IO ()
main = do
  ds <- fmap (reverse . words) getLine
  print $ fst $ calc ds

-- ??????????????????????????¨???????????£??¨?°???????????????????????°???????????????????

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

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

	int n,k;

	cin >> n >> k;

	vector <pair<int,int>> adj;

	if(k>((n-2)*(n-1)/2))
	{
		cout << -1 << '\n';
		return 0;
	}

	for(int i=2;i<=n;i++)
	{
		adj.push_back(make_pair(1,i));
	}

	int cnt = (n-2)*(n-1)/2;

	for(int i=2;i<=n;i++)
	{
		if(cnt==k)
		{
			break;
		}
		for(int j=i+1;j<=n;j++)
		{
			adj.push_back(make_pair(i,j));
			cnt--;
			if(cnt==k)
			{
				break;
			}
		}
		if(cnt==k)
		{
			break;
		}
	}		

	cout << adj.size() << '\n';
	for(int i=0;i<adj.size();i++)
	{
		cout << adj[i].first << ' ' << adj[i].second << '\n';
	}

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int number_n, number_k, i, point, distance = 0;
  scanf("%d", &number_n);
  scanf("%d", &number_k);
  for(i = 0; i < number_n; i++) {
    scanf("%d", &point);
    if(point > number_k - point) {
      distance += (number_k - point) * 2;
    } else {
      distance += point * 2;
    }
  }
  printf("%d\n", distance);
  return 0;
}


Measured memory_bytes: 128
from collections import deque
N, M = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    l, r, d = map(int, input().split())
    X[l-1].append((r-1, d))
    X[r-1].append((l-1, -d))

done = [0] * N
dist = [0] * N
def BFS(i):
    Q = deque([i])
    done[i] = 1
    while Q:
        x = Q.popleft()
        for y, d in X[x]:
            if done[y]:
                if dist[y] != dist[x] + d:
                    return 0
            else:
                done[y] = 1
                dist[y] = dist[x] + d
                Q.append(y)
    return 1

for i in range(N):
    if done[i] == 0:
        if BFS(i) == 0:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 79904
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1e8;
const int MOD = 1000000007;
int f(vector<P> a) {
   sort(a.begin(), a.end());
   int res = INF;
   rep(i, 1, a.size()) {
      if (a[i - 1].second == 0 && a[i].second != 0) {
         res = min(res, a[i].first - a[i - 1].first);
      }
   }
   return res;
}

int f(map<int, vector<P>>& mp) {
   int res = INF;
   for (auto p : mp) {
      res = min(res, f(p.second));
   }
   return res;
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   vector<int> x(n), y(n), dir(n);
   rep(i, 0, n) {
      char c;
      cin >> x[i] >> y[i] >> c;
      if (c == 'U') dir[i] = 0;
      if (c == 'R') dir[i] = 1;
      if (c == 'D') dir[i] = 2;
      if (c == 'L') dir[i] = 3;
   }
   int ans = INF;
   rep(ri, 0, 4) {
      {
         // UD
         map<int, vector<P>> mp;
         rep(i, 0, n) {
            if (dir[i] != 0 && dir[i] != 2) continue;
            mp[x[i]].emplace_back(y[i], dir[i]);
         }
         ans = min(ans, f(mp) * 5);
      }
      {
         // UR
         map<int, vector<P>> mp;
         rep(i, 0, n) {
            if (dir[i] != 0 && dir[i] != 1) continue;
            mp[x[i] + y[i]].emplace_back(y[i], dir[i]);
         }
         ans = min(ans, f(mp) * 10);
      }
      // rotate
      rep(i, 0, n) {
         int px = x[i], py = y[i];
         x[i] = py;
         y[i] = -px;
         dir[i] = (dir[i] + 1) % 4;
      }
   }
   if (ans == INF)
      cout << "SAFE" << endl;
   else
      cout << ans << endl;
   return 0;
}

Measured memory_bytes: 27020
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 +c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
const int maxn = 5e5 + 5,maxm = 1e6 + 5;;

int N,M,Q,MOD,f[maxn],t[maxn],v[maxn];
int fa[maxm * 6],z,g;
bool able[2][maxm];
int id(int u,int p,int q) {
    return (u - 1) * 6 + p * 3 + q + 1;
}
int gcd(int a,int b) {
    return b == 0 ? a : gcd(b,a % b);
}
int getfa(int u) {
    return u == fa[u] ? u : fa[u] = getfa(fa[u]);
}
void Merge(int u,int v) {
    fa[getfa(u)] = getfa(v);
}
void Init() {
    read(N);read(M);read(Q);read(MOD);
    read(f[1]);read(t[1]);read(v[1]);
    g = MOD;
    for(int i = 2 ; i <= M ; ++i) {
    read(f[i]);read(t[i]);read(v[i]);
    g = gcd(g,abs(v[i] - v[1]));
    }
    MOD = gcd(MOD,3 * g);
    z = v[1] % g;
    int T = id(N,1,2);
    for(int i = 1 ; i <= T; ++i) fa[i] = i;
    for(int i = 1 ; i <= M ; ++i) {
    int w = (v[i]-z ) / g;
    for(int p = 0 ; p < 2 ; ++p) {
        for(int q = 0 ; q < 3 ; ++q) {
        Merge(id(f[i],p,q),id(t[i],p ^ 1,(q * 2 + w) % 3));
        Merge(id(t[i],p,q),id(f[i],p ^ 1,(q * 2 + w) % 3));
        }
    }
    }
    for(int i = 0 , j = z ; i < MOD ; ++i , j = j * 2 % MOD) able[i & 1][j] = 1;
}
void Solve() {
    int s,t,r;
    for(int i = 1 ; i <= Q ; ++i) {
    read(s);read(t);read(r);
    bool res = 0;
    for(int p = 0 ; p < 2 ; ++p) {
        for(int q = 0 ; q < 3 ; ++q) {
        if(getfa(id(t,0,0)) == getfa(id(s,p,q))) {
            if(able[p][(r + z + (3 - q) * g) % MOD]) res = 1;
        }
        }
    }
    if(res) puts("YES");
    else puts("NO");
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
}

Measured memory_bytes: 10624
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    vector<ll> dp(n,INF);
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        if(i+1 < n){
            dp[i+1] = min(dp[i+1],dp[i] + abs(a[i+1] - a[i]));
        }
        if(i+2 < n){
            dp[i+2] = min(dp[i+2],dp[i] + abs(a[i+2] - a[i]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

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

  if(N==0){
    cout << X << endl;
    return 0;
  }

  set<int> s;
  rep(i,300) s.insert(i-100);

  int input;

  rep(i,N){
    cin >> input;
    s.erase(input);
  }

  if(N==100){
    if (X>50)
      cout << 101 << endl;
    else
      cout << 0 << endl;
    return 0;
  }

  set<int>::iterator it;
  it=s.find(X);
  if(it != s.end()){
    cout << X << endl;
    return 0;
  }

  int x=0;
  while(1){
      if(s.find(X-x)!=s.end()){
        cout << X-x << endl;
        break;
      }
      if(s.find(X+x)!=s.end()){
        cout << X+x << endl;
        break;
      }
    x++;
  }



}

Measured memory_bytes: 3640
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  ss <- sort <$> replicateM n readLn :: IO [Int]
  let non10 = filter (\s -> s `mod` 10 /= 0) ss
  let sumAll = sum ss
  print $ if sumAll `mod` 10 /= 0
              then sumAll
              else if null non10
                    then
                      0
                    else
                      sum ss - head non10


Measured memory_bytes: 1020
n,x,y=map(int,input().split())
dist=[[0 for i in range(n)] for j in range(n)]
m=n
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[i].append(i+1)
for i in range(1,n):
  connection[i].append(i-1)
connection[x-1].append(y-1)
connection[y-1].append(x-1)

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

ct=[0 for i in range(n)]

for i in range(n):
  b=bfs(i)
  for j in range(n):
    ct[b[j]]+=1

for i in range(1,n):
  print(ct[i]//2)

Measured memory_bytes: 93660
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	str s;
	cin >> s;
	rep(i, s.size())
	{
		if (s[i] == ',')
			cout << " ";
		else
			cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned) 1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  bitset<100000> bs;
  while (m--) {
    int a; cin >> a;
    bs[a] = true;
  }
  V<Mint> dp(n + 1);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) if (!bs[i]) {
    dp[i + 1] += dp[i];
    if (i + 2 <= n) dp[i + 2] += dp[i];
  }
  cout << dp[n] << '\n';
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    int n,m;cin>>n>>m;
    vector<int> food(m+1,0);
    rep(i,n){
        int k;cin>>k;
        rep(j,k){
            int a;cin>>a;
            food[a]++;
        }
    }
    int res=0;
    rep1(i,m){
        if(food[i]==n)res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat 
using namespace std;
typedef long long LL;
typedef double ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int SIZE=3*1000;
const int BITSIZE=1<<17;
const int TIMES=40;
const LL p=7+1e9;
LL N,M,K,H,W,C;
string solve(int a,int b){
	if(a<=0 && 0<=b ) return "Zero";
	if(0<a) return "Positive";
	if((-(a-min(0,b+1)))&1) return "Negative";
	return "Positive";
}
int main(){
	int a,b;
	cin >> a >> b;
	cout << solve(a,b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, k, l, x, sum;


  while(scanf("%d",&x) != EOF){
    sum = 0;

    for(i = 0; i < 10; i++){
      for(j = 0; j < 10; j++){
	for(k = 0; k < 10; k++){
	  for(l = 0; l < 10; l++){
	    if(i + j + k + l == x){
	      sum += 1;
	    }
	  }
	}
      }
    }
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll balance=100;
  	ll target;
   while(cin>>target){
     int cnt=0;
   	while(balance<target){
    	balance+=balance/100;
       cnt++;
    }
     cout<<cnt<<endl;
   }
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
typedef long long ll;



int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    int mx = max(max(a,b),c);
    int ans = a + b + c - mx;
    for(int i=0; i<k; i++) mx *= 2;
    cout << ans + mx << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int k = in.nextInt();
        int n = in.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++) a[i] = in.nextInt();
        int dist = a[0]+k-a[n-1];
        for(int i=0;i<n-1;i++){
            dist = Math.max(a[i+1]-a[i],dist);
        }
        out.println(k-dist);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 47828
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int K;
  string S;
  cin>>K>>S;
  
  if((int)S.size()<=K){
    cout<<S<<endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
  
 
}

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

#define NS (100005)
#define FIR first
#define SEC second

using namespace std;

typedef pair<int, int> PII;

template <typename _Tp> inline void IN(_Tp& dig)
{
	char c; bool flag = 0; dig = 0;
	while (c = getchar(), !isdigit(c)) if (c == '-') flag = 1;
	while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
	if (flag) dig = -dig;
}

int n, fa[NS];

map<PII, int> mp;

set<int> g[NS];

queue<PII> que;

int findf(int a) {return fa[a] == a ? a : fa[a] = findf(fa[a]);}

int main(int argc, char const* argv[])
{
	IN(n);
	for (int i = 1; i <= n; i += 1) fa[i] = i;
	for (int i = 1, a, b; i < n; i += 1)
	{
		IN(a), IN(b);
		if (a > b) swap(a, b);
		mp[PII(a, b)]++;
		g[a].insert(b), g[b].insert(a);
	}
	for (int i = 1, a, b; i < n; i += 1)
	{
		IN(a), IN(b);
		if (a > b) swap(a, b);
		if (++mp[PII(a, b)] == 2) que.push(PII(a, b));
		g[a].insert(b), g[b].insert(a);
	}
	int cnt = 0;
	while (!que.empty())
	{
		int u = findf(que.front().FIR), v = findf(que.front().SEC); que.pop();
		if (g[u].size() > g[v].size()) swap(u, v);
		for (set<int>::iterator i = g[u].begin(); i != g[u].end(); i++)
			if (*i != v)
			{
				g[*i].erase(u), g[*i].insert(v), g[v].insert(*i);
				int a = *i, b = v;
				if (a > b) swap(a, b);
				if (++mp[PII(a, b)] == 2) que.push(PII(a, b));
			}
		g[v].erase(u), fa[u] = v, cnt++;
	}
	if (cnt == n - 1) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 43520
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}

int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
string p;
char ch='A';
for(int i=0;i<n;i++)
{
	if(ch!=s[i])
	{
		p.pb(s[i]);
		ch=s[i];
	}
}
cout<<p.length()<<endl;
}



Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pi acos(-1)
#define mod 1000000007
#define inf INT_MAX
ll a[10000005];
int main()
{
    ll i,j,k,n,t,ans=0;
    cin>>n;
    for(i=0; i<=n; i++)
        a[i]=0;
    for ( i = 1; i <= n; ++i)
        for ( j = i; j <= n; j += i)
            a[j]++;
            
    for(i=1;i<=n;i++)
        ans+=(i*a[i]);
    cout<<ans<<endl;



}




Measured memory_bytes: 81744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, k,in;
	vi hate;
	cin >> n >> k;
	rep(i, k) {
		cin >> in;
		hate.push_back(in);
	}
	for (int i = n;; i++) {
		bool sw = true;
		string s = to_string(i);
		rep(j, s.size()) {
			rep(l, k) {
				if (s[j] - '0' == hate[l]) {
					sw = false; break;
				}
			}
		}
		if (sw) {
			cout << i << endl;
			return 0;
		}
	}
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9



int main(){
  int A, B;
  cin >> A >> B;
  if(A==B){
    cout << "Draw" << endl;
  }
  else if(A == 1 || (B!= 1 &&A > B)){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;

  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, L;
  scanf("%d%d", &n, &L);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i + 1 < n; i++) {
    if (a[i] + a[i + 1] >= L) {
      printf("Possible\n");
      for (int j = 0; j < i; j++) {
        printf("%d\n", j + 1);
      }
      for (int j = n - 2; j >= i + 1; j--) {
        printf("%d\n", j + 1);
      }
      printf("%d\n", i + 1);
      return 0;
    }
  }
  printf("Impossible\n");
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main(){
  int n, m;
  int h, r;
  while(cin >> n, n){
    vector<P> v;
    for(int i = 0 ; i < n ; i++){
      cin >> h >> r;
      v.push_back(P(h, r));
    }
    cin >> m;
    for(int i = 0 ; i < m ; i++){
      cin >> h >> r;
      v.push_back(P(h, r));
    }
    sort(v.begin(), v.end());
    
    int dp[210];
    memset(dp, 0, sizeof(dp));
    
    int ans = -1;
    
    for(int i = 0 ; i < (int)v.size() ; i++){
      for(int j = 0 ; j < i ; j++){
	if(v[i].first > v[j].first && v[i].second > v[j].second)
	  dp[i] = max(dp[i], dp[j]+1);      
      }
      ans = max(ans, dp[i]);
    }
    
    cout << ans+1 << endl;
    
  }

  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int ans;
	int a, b,c;

	cin >> a >> b >> c;
	
	ans = a * 100 + b * 10 + c;

	if (ans %4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private FastScanner sc;
  private Scanner scc;

  private void run() {
    sc = new FastScanner();
    int N = sc.nextInt();
    int X = sc.nextInt();

    int next = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
      int tmp = sc.nextInt();
      next += tmp;
      if (X < next) {
        break;
      }
      count++;
    }

    System.out.println(count + 1);
  }
}


class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
      return buffer[ptr++];
    else
      return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
      ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
      throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
      throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
      throw new NumberFormatException();
    return (int) nl;
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var a = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            var result = list.Max() - list.Min();
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28256
n = int(input())

li = [0]*100
for i in range(n+1):
    li[int(str(i)[0]+str(i)[-1])]+=1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += li[int(str(i)+str(j))] * li[int(str(j)+str(i))]

print(ans)


Measured memory_bytes: 9192
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))

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

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

        if x == y:
            return

        self.parents[y] = x
        
n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)

size = 0
for i in range(n):
    if uf.parents[i] == i:
        size += 1
print(size-1)

Measured memory_bytes: 12696
#include<stdlib.h>
#include<stdio.h>

int main(void)
{
    int acc,pen;

    int N,M;
    char scanbuf[3];
    int P[100010],S[100010];
    int accFlag[100010];

    acc=pen=0;

    for(int i=0;i<100010;i++){
        accFlag[i]=0;
        S[i]=0;
    }

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

    for(int i=1;i<=M;i++){
        scanf("%d %s",&P[i],scanbuf);
        if(accFlag[P[i]] == 0){
            if(scanbuf[0]=='A'){
                acc++;
                pen+=S[P[i]];
                accFlag[P[i]]=1;
            }else{
                S[P[i]]++;
            }
        }
    }

    printf("%d %d",acc,pen);

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  string s = to_string(n);

  int sum = 0;
  rep(i, s.size()) sum += s[i] - '0';

  cout << (n%sum == 0 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  double T,A;
  cin>>N>>T>>A;
  vector<pair<double,int>> H(N);
  for(int i=0;i<N;i++){
    double h;
    cin>>h;
    H.at(i).first=abs(T-0.006*h-A);
    H.at(i).second=i+1;
  }
  sort(H.begin(),H.end());
  cout<<H.at(0).second<<endl;

}


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

int main() {
  int n,k;
  cin >>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long long kotae=LLONG_MAX;
  for (int i = 0; i < (1 << n); i++) {
    int bit[15];
	for (int j = 0; j < n; j++){
      bit[j] = (i / (1 << j)) % 2;
    }
    long long sa=0;
    int kazu=1;
    int start=a[0];
    for(int j=1;j<n;j++){
      start=max(a[j-1],start);
      if(bit[j]==0)continue;
      if(bit[j]==1){
        kazu++;
        if(a[j]>start){
          start=a[j];
        }else{
          start++;
          sa+=start-a[j];
          //cout<<" sa:"<<start-a[j]<<endl;
        }
      }
    }
    //cout<<kazu<<" "<<sa<<endl;
    if(kazu>=k)kotae=min(kotae,sa);
  }
  cout<<kotae<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#include <iomanip> 
#include<map>
using namespace std;
bool d8(int b){
	int c = 0;
	for (int i = 1; i <= b; i++){
		if (b%i == 0){
			c++;
		}
	}
	if (c == 8){
		return 1;
	}
	return 0;
}
int main()
{
	int n;
	cin >> n;
	
		int c = 0;
		for (int i = 1; i <= n; i++){
			if (i%2==1){
				if (d8(i)){
					c++;
				}
			}
		}
		cout << c;
}

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

int main() {
    int N;
    cin >> N;
    bool can = false;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == N) {
                can = true;
                break;
            }
        }
        if (can) break;
    }
    if (can) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
a=[int(x)//2 for x in input().split()]

def lcm(a,b):
  if a>b:
    a,b=b,a
  if a==1:
     return b
  n=a*b
  while a!=0:
    b,a=a,b%a
  return n//b

f1,f2=a[0],a[0]
for i in range(1,N):
  f1|=a[i]
  f2&=a[i]
c=0
while f1&1==0:
  f1//=2
  c+=1
if f2&2**c==0:
  print(0)
  exit()

t=a[0]
for i in range(1,N):
  t=lcm(t,a[i])
  if t>M:
    print(0)
    break
else:
  print(M//t-M//(t*2))


Measured memory_bytes: 15060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll r;cin>>r;print(r*r);
  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 n = sc.nextInt();
    int[]a = new int[n];
    
    int cou = 0;
    for(int i=0; i<n; i++) {
    	a[i] = sc.nextInt();
    	if(a[i]%2 == 0) {
    		if(a[i]%3!=0 && a[i]%5!=0) {
    		cou++;
    	}
    }
    }
    	if(cou == 0) {
    	System.out.println("APPROVED");
    	}else {
    	System.out.println("DENIED");
    }
      }
}


Measured memory_bytes: 35852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000000000000000
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define rep(i, a, b) for (ll i = (a); i <= ll(b); i++)
#define pii pair<ll, pair<ll, char>>
#define fr for(ll i = 0; i < n; i++)
ll n;
vector<ll>a;
vector<bool>vis;
vector<int>adj[200005];
void dfs(int u, int &sz) {
	vis[u] = true;
	sz++;
	for(int v : adj[u]) {
		if(!vis[v]) {
			dfs(v, sz);
		}
	}
}
int solve() {
	int m;
	cin>>n>>m;
	a.resize(n);
	vis.resize(n+1, false);
	for(int i = 0; i < m; i++) {
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int ans = 1;
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			int sz = 0;
			dfs(i, sz);
			ans = max(ans, sz);
		}
	}	
	return ans;
}
int main() {
	io
	ll t = 1;
	//cin>>t;
	while(t--) {
		cout<<solve()<<endl;
		//solve();
	}
}


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

typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999



int main(){
    int n;
    cin>>n;
    int data[200][200];
    rep(i,n)rep(j,n){
        cin>>data[i][j];
    }
    
    int maxi = -1000000000;
    rep(i,n){
        rep(j,n){
            int dp[200][200]={};
            for(int k=i;k<n;k++){
                for(int l=j;l<n;l++){
                    dp[k][l] = (k-1>=i)*dp[k-1][l] + (l-1>=j)*dp[k][l-1] - (k-1>=i&&l-1>=j)*dp[k-1][l-1] + data[k][l];

                    maxi = max(maxi,dp[k][l]);
                }
            }
        }
    }
    cout<<maxi<<endl;
}

Measured memory_bytes: 1404