akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n; cin >> n;
    vector<int> x(n);
    vector<int> a(100);

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

    for (int j = 0; j < 100; ++j) {
        for (int i = 0; i < n; ++i) {
            a[j] += pow(x[i]-j+1, 2);
        }
    }

    cout << *min_element(a.begin(), a.end()) << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (a + b >= x && a <= x) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  std::cin.tie(nullptr);                 // 標準入出力高速化
  std::ios_base::sync_with_stdio(false); // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15); // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
class Tree():
  def __init__(s, n):
    s.L = [-1] * n
  def root(s, x):
    if s.L[x] < 0:
      return x, -s.L[x]
    a, b = s.root(s.L[x])
    s.L[x] = a
    return a, b
  def merge(s, a, b):
    ra, sa = s.root(a)
    rb, sb = s.root(b)
    if ra != rb:
      if sa < sb:
        s.L[ra] = rb
        s.L[rb] -= sa
      else:
        s.L[rb] = ra
        s.L[ra] -= sb
      return True
    return False


N, K, L = list(map(int, input().split()))
pq = [list(map(int, input().split())) for _ in range(K)]
rs = [list(map(int, input().split())) for _ in range(L)]

R = Tree(N)
T = Tree(N)

for a, b in pq:
  a -= 1
  b -= 1
  R.merge(a, b)

for a, b in rs:
  a -= 1
  b -= 1
  T.merge(a, b)

RL = [0] * N
for i in range(N):
  RL[i] = R.root(i)[0]

TL = [0] * N
for i in range(N):
  TL[i] = T.root(i)[0]

D = {}
for i in range(N):
  if RL[i] not in D:
    D[RL[i]] = {}
    D[RL[i]][TL[i]] = 1
  else:
    if TL[i] not in D[RL[i]]:
      D[RL[i]][TL[i]] = 1
    else:
      D[RL[i]][TL[i]] += 1

for i in range(N):
  print(D[RL[i]][TL[i]], end = " ")


Measured memory_bytes: 147588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,k;
	cin>>n>>k;
	ll a[100010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll b[100010];b[0]=0;
	for(ll i=1;i<n;i++){
		b[i]=a[i]-a[i-1]+b[i-1];
	}
	ll ans=INF;
	for(ll i=0;i+k<n+1;i++){
		ll now=b[i+k-1]-b[i];
		now+=min(abs(a[i+k-1]),abs(a[i]));
		ans=min(ans,now);
	//	cout <<ans<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N, K = map(int, input().split())

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(range(1, K + 1)):
        n_gcd[k] = pow(K // k, N, mod=P)
        for m in range(2, K // k + 1):
            n_gcd[k] -= n_gcd[k * m]
        n_gcd[k] %= P
        ans = (ans + k * n_gcd[k]) % P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 11224
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if (a[i] == 0) {
                System.out.println(0);
                return;
            }
        }

        BigDecimal bd = new BigDecimal(1);
        long th = (long) Math.pow(10, 18);
        for (int i = 0; i < n; i++) {
            if (th / bd.longValue() < a[i]) {
                System.out.println(-1);
                return;
            }

            bd = bd.multiply(BigDecimal.valueOf(a[i]));
            if (bd.longValue() > th) {
                System.out.println(-1);
                return;
            }
        }

        System.out.println(bd.longValue());
    }
}

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

int main(){
  int N;
  cin >>N;
  bool a=false;
  for(int i=0;i<=N/7 ;i++){
    for(int j=0;j<=N/4 ;j++){
      if(N==(7*i+4*j))
        a=true;
    }
  }
  if(!a)
    cout<<"No" <<endl;
  if(a)
    cout <<"Yes" <<endl;
}       


Measured memory_bytes: 256
N,L=map(int,input().split())
mem=sum(range(L,L+N))
m=mem
ans=0
for i in range(N):
    tmp=(sum(range(L,L+N))-(L+i))
    if abs(mem-tmp) < abs(m):
        m=mem-tmp
        ans=tmp
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30
#define MAX_P 1300000

int main(){
  bool f[MAX_P] = {};
  f[0] = f[1] = 1;
  REP(i, 2, MAX_P / 2 + 1){
    if(!f[i]){
      for(int j = i+i; j < MAX_P; j += i) f[j] = 1;
    }
  }

  //  rep(i, 100) if(!f[i]) printf("%d ", i); puts("");
  int n;
  while(scanf("%d", &n) && n){
    int a, b;
    for(int i = n; i >= 0; i--) if(!f[i]){ a = i; break;;}
    for(int i = n; i < MAX_P; i++) if(!f[i]){ b = i; break;;}
    printf("%d\n", b-a);
  }
  return 0;
}

Measured memory_bytes: 2464
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;
int n;
void dfs(int pos ,vector< vector<pair<int,int>> > &G, vector<int> &color){
    // cout << "now at " << pos << endl;
    for(auto x : G[pos]){
        if(color[x.first] != -1) continue;
        // cout << "next is " << x.first << endl;
        int p = (color[pos] + x.second)%2;
        color[x.first]=p;
        // rep(i,n) cout << color[i] << " ";cout << endl;
        dfs(x.first, G, color);
    }
    
    return;
}
int main(){
    cin >> n;
    vector< vector<pair<int,int>> > G(n, vector<pair<int,int>>(0));
    vector<int> color(n,-1);
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;

        G[u-1].push_back(make_pair(v-1,w));
        G[v-1].push_back(make_pair(u-1,w));
    }
    int root = -1;
    rep(i,n)
        if(G[i].size()==1) root = i;

    // rep(i,n) {
    //     cout << i << ":";
    //     rep(j,G[i].size()) cout << G[i][j].first << " ";
    //     cout << endl;}

    color[root] = 1;
    dfs(root, G, color);
    
    rep(i,n) cout << color[i] << " ";cout << endl;

    return 0;
}

Measured memory_bytes: 10240
#!/usr/bin/env python3

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += c[A[i][j]][1]

print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define MAXN 10000001
 
int main ()
{
    ll T;
    T=1;
   //cin>>T;
    while(T--)
    {	
	ll n,m,k,s=0;
	cin>>n>>m>>k;
	vl a(n+1,0),b(m+1,0);
	fori(i,1,n+1){
		ll x;
		cin>>x;
		s+=x;
		a[i]=s;//deb(a[i])
	}
		
	
	s=0;
		fori(i,1,m+1){
		ll x;
		cin>>x;
		s+=x;
		b[i]=s;
	//	deb(b[i])
		}
		
	
    ll ans=0,y,j=m,i;
  for( i=0;i<n+1;i++){
  	y=k-a[i];
  
  	if(y<0){break;}
  	else{
  		while(b[j]>y&&j>0){
  			j--;
  		}
  	
  	}
  	
  	ans=max(ans,i+j);
  	
  }
//  deb(i)deb(j)
  cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6368
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

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

    int need_left = 0, pointer = 0;//pointer は　小さい方の計算　needleftは大きく囲うための変数
    repi(i, n, 0)
    {
        if (s[i] == '(')
            ++pointer;
        else
        {
            if (pointer == 0)
                ++need_left;
            else
                --pointer;
        }
    }
    int need_right = pointer;

    string res = "";
    repi(i, need_left, 0) res += '(';
    res += s;
    repi(i, need_right, 0) res += ')';
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int K;
	cin >> K;
	K--;
	vector<int>v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << v[K] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> grid(h, vector<int>(w));
    for(int i = 0; i < h; i++)for(int j = 0; j < w; j++) cin >> grid[i][j];
    vector<pair<P, P>> ans;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i == h-1 && j == w-1) break;
            if(grid[i][j]&1^1) continue;

            if(j == w-1) {
                grid[i+1][j]++;
                P a = P(i, j);
                P b = P(i+1, j);
                ans.push_back(pair<P, P>(a, b));
            }else{
                grid[i][j+1]++;
                P a = P(i, j);
                P b = P(i, j+1);
                ans.push_back(pair<P, P>(a, b));
            }
        }
    }
    cout << ans.size() << endl;
    for(auto p : ans) {
        cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
    }
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
ll mod = 1000000007;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib> 
#include <string>

using namespace std;

int main() {
	int n;
	cin >>n;
	vector<int> a(n);
	for (int i=0;i<n;i++){
		cin >> a[i];
	}
	int ans=0,tmp=1;

	for (int i = 0; i < n-1; i++)
	{
		if(a[i]==a[i+1]){
			tmp++;
		}else {
			ans += tmp/2;
			tmp=1;
		}

	}
	ans += tmp/2;
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string S;
  string T;
  int count =0;
  int max=0;
  cin >> S >> T;
  int a=S.size()-T.size();
  int b=T.size();
  for(int i=0; i<a+1;i++){
    for(int j=0; j<b; j++){
      if(S.at(i+j)==T.at(j)){
        count++;
      }
    }
    if(max< count){
      max=count;
    }
    count=0;
  }
  cout<< T.size()-max<< endl;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)


typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

int n;
string s, t;
void Input() {

    cin >> n;
    cin >> s >> t;
}



void Solve() {


    string ans = "";

    for(int i = 0; i < n; i++) {

        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;

}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



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

int beki_100(int n){
    int ans=0;
    while(n%100==0){
        ans++;
        n/=100;
    }
    return ans;
}

int main(){
    int D,N;
    cin>>D>>N;
    int ans;
    int count=0;
    for(int i=1;;i++){    
        if(beki_100(i)==D){
            count++;
        }
        if(count==N){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

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

	cin >> a >> b >> c;

	int ans = 0;
	for (int i = a; i <= b; i++){
		if (c%i == 0){
			ans++;
		}
	}

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

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    int p[n*n];
    int dis[n][n],mov[n][n];
    rep(i,n){
        rep(j,n){
            dis[i][j] = min({i,j,n-1-i,n-1-j});
            mov[i][j] = 1;
        }
    }
    ll hate = 0;

    rep(i,n*n){
        int p;
        cin >> p;
        p--;
        // 4つのどの方角が少ないか計算
        int u,v;
        u = p/n;
        v = p%n;
        int dx[4] = {0,1,0,-1};
        int dy[4] = {1,0,-1,0};

        hate += dis[u][v];
        queue<pair<int,int>> que;
        que.push({u,v});
        mov[u][v] = 0;
        while(!que.empty()){
            int nu,nv;
            pair<int,int> np;
            np = que.front();
            que.pop();
            nu = np.first;
            nv = np.second;
            rep(j,4){
                int x = nu + dx[j];
                int y = nv + dy[j];
                if(x>=0&&x<n&&y>=0&&y<n&&dis[x][y]>dis[nu][nv]+mov[nu][nv]){
                    dis[x][y] = dis[nu][nv] + mov[nu][nv];
                    que.push({x,y});
                }
            }
        }
    }
    cout << hate << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  A--, B--, C--, D--;
  auto check = [&](int x, int y) {
    x++, y -= 2;
    for (int i = x; i <= y; i++) {
      if (S[i] == '#' && S[i + 1] == '#') return false;
    }
    return true;
  };
  if (C < D) {
    if (check(A, C) && check(B, D)) yes(); no();
  }
  bool f = false;
  for (int i = B - 1; i <= D - 1; i++) {
    if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
      f = true;
      break;
    }
  }
  if (!f) no();
  if (check(A, C) && check(B, D)) yes(); no();
}


Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    while (1) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int j = 0;j < w;j++) {
            cout << "#";
        }
        cout << endl;
        for (int i = 0; i < h-2; i++) {
            cout << "#";
            for (int j = 0;j < w-2; j++) {
                cout << ".";
            }
            cout <<"#"<< endl;
        }
        for (int j = 0;j < w;j++) {
            cout << "#";
        }
        cout << endl<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int x, a;
  cin >> x >> a;
  if (x < a)
    cout << 0 << endl;
  else
    cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
const int MAXN = 1e2 + 5;
const int mod = 1e9 + 7;

using namespace std;

ll dp[4][4][4][4][MAXN];
string s = "ACGT";
set<string> imp = {"AGTC","ATGC","TAGC","AGCT", "ACGT", "TACG", "GACT","TGAC"};

ll rec(int n, char a, char g, char c, char t) {
	string m = ""; m+=a;m+=g;m+=c;m+=t;
	if (imp.find(m) != imp.end()) return 0;
	if (n == 0) return 1;
	if (a == '#')
		return ((rec(n-1,g,c,t,'A')+rec(n-1,g,c,t,'C'))%mod+(rec(n-1,g,c,t,'G')+rec(n-1,g,c,t,'T'))%mod)%mod;
	int i = s.find(a), j = s.find(g), k = s.find(c), l = s.find(t);
	auto &ret = dp[i][j][k][l][n];
	if (ret != -1) return ret;
	return ret = ((rec(n-1,g,c,t,'A')+rec(n-1,g,c,t,'C'))%mod+(rec(n-1,g,c,t,'G')+rec(n-1,g,c,t,'T'))%mod)%mod;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int ans[4] = {0,4,16,61};
  memset(dp,-1,sizeof dp);
  for (string k : imp) {
  	int id = k.find('T');
  	if (id == string::npos) continue;
  	for (int i = 0; i < 3; i++) {
  		k[id] = s[i];
  		imp.insert(k);
  	}
  }
  if (n <= 3) cout << ans[n];
  else cout << rec(n,'#','#','#','#');
  return 0;
}

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

int main() {
  int N,i,j,count,sum=0;
  
  cin >> N;
  
  for(i=1;i<=N;i+=2) {
    count = 0;
    for(j=1;j<=N;j++) {
      if(i%j==0) count++;
    }
    if(count==8) sum++;
  }
  
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define MOD 1000000007
ll dp[300][300];
int n;
char c[300];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)cin >> c[i];
    dp[0][0]=1ll;
    for(int i=0;i<n;i++)
    {
        if(c[i]=='-')for(int j=0;j<=n;j++)dp[i+1][j]=dp[i][j];
        if(c[i]=='D')
        {
            for(int j=0;j<=i;j++)
            {
                if(j>0)dp[i+1][j-1] = (dp[i+1][j-1]+(((dp[i][j]*j)%MOD)*j%MOD))%MOD;
                dp[i+1][j] = (dp[i+1][j]+((dp[i][j]*j)%MOD))%MOD;
            }
        }
        if(c[i]=='U')
        {
            for(int j=0;j<=i;j++)
            {
                dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
                dp[i+1][j] = (dp[i+1][j]+((dp[i][j]*j)%MOD))%MOD;
            }
        }
    }
    printf("%lld\n",dp[n][0]);
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int DP[1001][1001];
int main(){
	string S,T;
	cin>>S>>T;
	FOR(i,0,S.size()){
		DP[i][0]=1;
	}
	FOR(j,0,T.size()){
		FOR(i,0,S.size()){
			DP[i+1][j+1]+=DP[i][j+1];
			if(S[i]==T[j]){
				(DP[i+1][j+1]+=DP[i][j])%=mod;
			}
		}
	}
	cout<<DP[S.size()][T.size()]<<endl;
	return 0;
}


Measured memory_bytes: 7140
import std.stdio, std.string, std.conv;
import std.math;
 
auto solve(string s_)
{
    immutable n = s_.to!long();
    immutable s = readln.chomp.to!long();
    if(s==n) return s+1;
    immutable m = sqrt(n.to!real()).to!long+1;
    foreach(i;2..m)
    {
        long v=n, c=0;
        while(v) c+=v%i, v/=i;
        if(c==s) return i;
    }
    foreach_reverse(i;1..m)
    {
        auto v1=n/i, v2=n/(i+1), r=s-i-(n%(n/i)), v=v1-r/i;
        if(r>=0 && r%i==0 && v2<v && v<=v1 && v>i)
            return v;
    }
    return -1;
}

void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    string s;
    cin >> s;
    rep(i,3) {
      if(s[i] == '7') {
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 5976
while line = gets
  (a, b, c, d, e, f) = line.split().map(&:to_f)
  z = a*e - b*d
  x = (c*e - b*f) == 0 ? 0.0 : (c*e - b*f) / z
  y = (a*f - c*d) == 0 ? 0.0 : (a*f - c*d) / z
  puts sprintf("%.3f %.3f", x, y)
end

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int n;
  cin >> n;
  ll c[10][10];
  rep(i, 0, 10){
    rep(j, 0, 10){
     c[i][j] = 0;
    }
  }
  
  rep(i, 0, n+1){
    char f, e;
    string s = to_string(i);
    f = s[0];
    e = s[s.size() - 1];
    int a, b;
    a = f-'0';
    b = e-'0';
    c[a][b]++;
  }
  
  ll sum = 0;
  
  rep(i, 1, 10){
    rep(j, i, 10){
      if(i == j)
        sum += (c[i][j]*c[i][j]);
      else
        sum += c[i][j]*c[j][i]*2;
    }
  }
  cout << sum << endl;
  
  return 0;
  
}

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

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

    int n,d;
    cin>>n;
    
    d = n%10;
    
    if(d==2 || d==4 || d==5 || d==7 || d==9){
        cout<<"hon"<<"\n";
    } else if(d==0 || d==1 || d==6 || d==8){
        cout<<"pon"<<"\n";
    } else {
        cout<<"bon"<<"\n";
    }

    return 0;
}

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

using namespace std;

int X,Y;

void input(){
  cin >> X >> Y;
}

int main(){
  input();  
  for(int i=0;i<X+1;i++){
    if((2*X+2*i)==Y){
      cout << "Yes"<<endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int n,w;
  cin>>n>>w;
  vector<vector<long>> dp(w+1,vector<long>(n,0));
  for(int i=0;i<n;i++)
  {
    long we,va;
    cin>>we>>va;
    for(int j=0;j<w+1;j++)
    {
      if(i==0){dp[j][i]=(j>=we)*va;continue;}
      if(j>=we){dp[j][i]=max(dp[j-we][i-1]+va,dp[j][i-1]);}
      else dp[j][i]=dp[j][i-1];
    }
  }
  cout<<dp[w][n-1];
  return 0;

}

Measured memory_bytes: 82304
#include <cstdio>
#include <algorithm>
#include <limits.h>
using namespace std;

const int N = 100 + 5;
int b[N], n;
int tot;

int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n - 1; ++i) {
		scanf ("%d", &b[i]);
	}
	tot += b[1];
	for (int i = 2; i < n; ++i) {
		tot += min (b[i], b[i - 1]);
	}
	tot += b[n - 1];
	printf ("%d\n", tot);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
using namespace std;
using ll = long long;

const ll N = 1e18;

int main() {
    int n;
    cin >> n;
    cpp_int a[n];
    cpp_int ans = 1;

    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);

    if(a[0] == 0) {
        cout << 0 << endl;
        return 0;
    }

    for(int i = 0; i < n; i++) {
        ans *= a[i];
        if(ans > (cpp_int)N) {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6832
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt() % 10;

        if (n == 3) {
            System.out.println("bon");
            return;
        }
        if (n == 0 || n == 1 || n == 6 || n == 8) {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35748
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        if (lhs.real() < rhs.real() - eps) return true;
        if (lhs.real() > rhs.real() + eps) return false;
        return lhs.imag() < rhs.imag();
    }
}
Point input_point() {ld x, y; cin >> x >> y; return Point(x, y);} // ????????\???
bool eq(ld a, ld b) {return (abs(a - b) < eps);} // ????????????????????????
ld dot(Point a, Point b) {return real(conj(a) * b);} // ??????
ld cross(Point a, Point b) {return imag(conj(a) * b);} // ??????

// ??´????????????
class Line {
public:
    Point a, b;
    Line() : a(Point(0, 0)), b(Point(0, 0)) {}
    Line(Point a, Point b) : a(a), b(b) {}
    Point operator[](const int _num) {
        if (_num == 0)return a;
        else if (_num == 1)return b;
        else assert(false);
    }
};

// ????????????
class Circle {
public:
    Point p;
    ld r;
    Circle() : p(Point(0, 0)), r(0) {}
    Circle(Point p, ld r) : p(p), r(r) {}
};

// CCW
int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if (cross(b, c) > eps) return 1;   // a,b,c??????????¨???¨?????????????????¶
    if (cross(b, c) < -eps) return -1; // a,b,c???????¨???¨?????????????????¶
    if (dot(b, c) < 0) return 2;       // c,a,b???????????´???????????¶
    if (norm(b) < norm(c)) return -2;  // a,b,c???????????´???????????¶
    return 0;                          // a,c,b???????????´???????????¶
}

/* ????§???¢ */
typedef vector<Point> Polygon;
// ???????§???¢?????´???
ld convex_diameter(const Polygon& poly){
    int n = (int)poly.size();
    int ii = 0, jj = 0;
    for(int i = 1;i < n;i++){
        if(poly[i].imag() > poly[ii].imag())ii = i;
        if(poly[i].imag() < poly[jj].imag())jj = i;
    }
    ld res = abs(poly[ii] - poly[jj]);
    
    int i, maxi,j,maxj;
    i = maxi = ii; j = maxj = jj;
    do{
        if(cross(poly[(i+1)%n] - poly[i],poly[(j+1)%n] - poly[j]) >= 0) j = (j+1)%n;
        else i = (i+1)%n;
        if(abs(poly[i] - poly[j]) > res){
            res = abs(poly[i] - poly[j]);
            maxi = i; maxj = j;
        }
    }while(i != ii || j != jj);
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    Polygon ps;
    for(int i = 0; i < n;i++) ps.emplace_back(input_point());
    cout << fixed << setprecision(10) << convex_diameter(ps) << endl;
    return 0;
}

Measured memory_bytes: 7016
#include<iostream>
#include<set>
using namespace std;
int main(){
  
  int n,a,b;
  set<int> se;

  cin >> n;
  while(n--){
    cin >> a >> b;
    if(a == 0){
      se.insert(b);
      cout << se.size() << endl;
    }
    if(a == 1){
      if(se.find(b) != se.end()) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  
  return(0);
}



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

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

    int min = 0;
    while (m--) {
        int e;
        cin >> e;

        idx[e-1] = min = min - 1;
    }

    vector<pair<int,int> > v;
    for (int i = 0; i < n; i++) {
        v.push_back(make_pair(idx[i], i));
    }

    sort(v.begin(), v.end());

    for (auto i : v) {
        cout << i.second+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 5692
#include "bits/stdc++.h"
using namespace std;
const int INF = 1 << 30;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	long long ans = -1e18;
	for (int i = 1; i < N - 1; ++i) {//
		long long score = 0;
		set<int>s;
		for (int x = 0;; ++x) {//
			//範囲外
			if (N - 1 - x * i < 0) {
				break;
			}
			//範囲外
			if ((x + i) >= N) {
				break;
			}
			//aの確認
			int a = N - 1 - i * x;
			if (a <= 0) {
				break;
			}
			//bの確認
			int b = a - i;
			if (b <= 0) {
				break;
			}
			//重複チェック
			if (s.count(x * i)) {
				break;
			}
			s.insert(x*i);
			//重複チェック
			if (s.count(N - 1 - x * i)) {
				break;
			}
			s.insert(N - 1 - x * i);

			score += A[x * i];
			score += A[N - 1 - x * i];
			/*
			cout << score << endl;
			cout << x * i << " " << N - 1 - x * i << endl;
			cout << i << " " << x << endl;
			cout << " " << endl;
			*/
			ans = max(ans, score);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8272
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
  char a[8]="AtCoder";
  char b[8]="Contest";
  char s[101];
  cin>>a>>s>>b;
  cout<<a[0]<<s[0]<<b[0]<<endl;
  return 0;
}

Measured memory_bytes: 256
"""
前処理として、各地点で両替した場合に最終的に残るスヌークを計算しておく。
これは、s地点から各地点までの円での最小コストと t地点から各地点までのスヌークでの最小コストを計算することで可能である。
次に、各地点で両替した場合に残るスヌークを昇順で保持しておく。
これで前処理は完了。

あとは、小さい順に残スヌークを取り出し、その両替地点の番号がi以下であれば、新しい最小値を取り出し、そうでなければ、その値を出力する。
"""
def main():
    import sys
    input = sys.stdin.readline
    import heapq
    n,m,s,t = map(int,input().split())
    def dijkstra(edges,costDic,startPoint):
        que=[(0,startPoint)]
        heapq.heapify(que)
        while que:
            cost,now = heapq.heappop(que)
            if now not in costDic:
                costDic[now] = cost
                for nx,c in edges[now]:
                    if nx not in costDic:
                        heapq.heappush(que,(cost+c,nx))

    yenEdges = [[] for _ in range(n+1)]
    snuukEdges = [[] for _ in range(n+1)]
    for _ in range(m):
        u,v,a,b = map(int,input().split())
        yenEdges[u].append((v,a))
        yenEdges[v].append((u,a))
        snuukEdges[u].append((v,b))
        snuukEdges[v].append((u,b))
    yenDic = {}
    snuukDic = {}

    dijkstra(yenEdges,yenDic,s)
    dijkstra(snuukEdges,snuukDic,t)

    remainingSnuuk = []
    for i in range(1,n+1):
        remainingSnuuk.append((10**15-(yenDic[i]+snuukDic[i]),i))
    remainingSnuuk.sort(key=lambda x: x[0], reverse=True)

    j = 0
    for i in range(n):
        while remainingSnuuk[j][1] <= i:
            j += 1
        print(remainingSnuuk[j][0])
main()

Measured memory_bytes: 121648
#include <stdio.h>
int main(void){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a<b  && b<c)
    printf("Yes\n");
   
   else
   printf("No\n");
    
    
    
    return 0;
    
}



Measured memory_bytes: 2600
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    vector<int> h(n);
    for(int& x:h)
    {
        cin>>x;
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j:{i+1,i+2})
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));

            }
        }
    }
    cout<<dp[n-1];
	return 0;
}


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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);

  int tot = 0;
  for (int i = 0; i < N; i++)
  {
    int cnt = 0;
    cnt += 1 + (D-1) / A.at(i);
    tot += cnt;
  }

  cout << tot + X << endl;
}

Measured memory_bytes: 256
l = input().split()
l = list(map(int, l))
if l[0] > l[1]:
    l[0],l[1] = l[1],l[0]

if l[1] > l[2]:
    l[1],l[2] = l[2],l[1]

if l[0] > l[1]:
    l[0],l[1] = l[1],l[0]

print(f"{l[0]} {l[1]} {l[2]}")   



Measured memory_bytes: 5612
/*input
8 5
-9 -7 -4 -3 1 2 3 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn];

int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	REP(i,n) cin>>a[i];

	ll ans=INF64;
	for(int i=0;i+k<=n;i++){
		ll l=a[i],r=a[i+k-1];
		ll cur;
		if((l>0)^(r>0)){
			cur=r-l+min(abs(l),abs(r));
		}
		else{
			cur=max(abs(l),abs(r));
		}
		ans=min(ans,cur);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	int p=0;
	scanf("%d",&n);
	while(n!=0)
	{
		if(n%10==7)
		p=1;
		n=n/10;
	}
	if(p==1)
	printf("Yes");
	else
	printf("No");
	return 0;
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	int a[n+2];
	ll sum = 0;
	a[0] = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum += abs(a[i] - a[i-1]);
	}
	a[n+1] = 0;
	sum += abs(a[n]);

	for (int i = 1; i <= n; ++i) {
		ll ans = 0;
		ans = sum - (abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]));
		ans += abs(a[i+1]-a[i-1]);
		cout << ans << "\n";
	}

}


Measured memory_bytes: 1664
def fibr(n):
    if arr[n] != 0:
        return arr[n]
    if n < 2:
        arr[n] = 1
    else:
        arr[n] = fibr(n-1) + fibr(n-2)
    return arr[n]

n = int(input())
arr = [0 for i in range(n+1)]
print(fibr(n))


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
bool is_pal(string& s)
{
    string rev = s;
    reverse(all(rev));
    return rev == s;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int n = sz(s);
    string a, b;
    for (int i = 0; i < n / 2; i++)
        a += s[i];
    for (int i = n / 2 + 1; i < n; i++)
        b += s[i];
    if (is_pal(a) && is_pal(b) && is_pal(s))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))
cst = [float('inf')] * n

cst[0] = 0
for _ in range(0, n-2):
    cst[_+1] = min(cst[_] + abs(lst[_+1] - lst[_]),cst[_+1])
    cst[_+2] = min(cst[_] + abs(lst[_+2] - lst[_]),cst[_+2])
cst[n-1] = min(cst[n-2] + abs(lst[n-1] - lst[n-2]),cst[n-1])
print(cst[n-1])

Measured memory_bytes: 13928
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();//0,1,2
    int N = sc.nextInt();
    
    int ans = N;
    if (D == 0 && N == 100) {
            ans++;
        } else if (0 < D) {
            for (int i = 0; i < D; i++) {
                ans *= 100;
            }
            if (N == 100) {
                int add = 1;
                for (int i = 0; i < D; i++) {
                    add *= 100;
                }
                ans += add;
            }
        }
    System.out.println(ans);
  }
}
    

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

using namespace std;

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  
  int total = 0;
  
  for (int i=1; i<=N; ++i)
  {
    const string s = to_string(i);
    
    int calc = 0;
    
    for (char c : s)
    {
      calc += c - '0';
    }
    
    if ((A <= calc) && (calc <= B))
    {
      total += i;
    }
  }
  
  cout << total << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
#include <numeric>
#include <utility>
#include<math.h>
#include<functional>
#include<queue>
#include<sstream>
#include<stack>
#include<algorithm>

int solve(int A,int B,int X){
    if(X-A<B&&X-A>=0)std::cout<<"YES";
    else std::cout<<"NO";
    return 0;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int A,B,X;
    std::cin>>A>>B>>X;
    return solve(A,B,X);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
  int n,d,x;
  cin>>n>>d>>x;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  rep(i,n){
    rep(j,d){
      if(v[i]*j+1<=d) x++;
    }
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

ll r;
vector<int> a;

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    int dfs(int i, int p) {
        int c = 1;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;
            int t = dfs(o.i, i);
            c += t;
            r -= a[t] - 1;
        }
        r -= a[n - c] - 1;
        r -= 1;
        r += a[n - 1];
        return c;
    }
    void solve() {
        r = 0;
        a = vector<int>(n + 1);
        a[0] = 1;
        for (int i = 0; i < n; i++) {
            a[i + 1] = a[i] * 2 % P;
        }
        dfs(0, -1);
        r %= P;
        if (r < 0) r += P;
        r = r * inv(a[n]) % P;
        cout << r << endl;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        g.add_edge(a, b);
        g.add_edge(b, a);
    }

    g.solve();

    return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
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 t[5];
  int k;
  REP(i, 5) cin >> t[i];
  cin >> k;
  bool flag = true;
  REP(i, 5){
    REP(j, 5){
      if(i == j) continue;
      if(abs(t[j] - t[i]) > k) flag = false;
    }
  }
  cout << (flag ? "Yay!" : ":(") << endl;
}

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

// 1~Nの並び替え

const int MAX_N = 1e5 + 10;
int N,K;
int A[MAX_N];

// start_pos から始める
int simulate_from(int start_pos)
{
  int ans = 0;                  // 操作回数
  // 手前に
  int i = start_pos;                 // どこまで1になったか
  while (i > 0) {
    i -= K - 1;
    ++ans;
  }
  // 後ろに
  i = start_pos;
  while (i < N - 1) {
    i += K - 1;
    ++ans;
  }
  return ans;
}

int main()
{
  cin >> N >> K;
  REP(i,0,N) cin >> A[i];

  // 1を探す position of 1
  int pos1 = -1;
  REP(i,0,N) {
    if (A[i] == 1) {
      pos1 = i; break;
    }
  }
  assert(pos1 >= 0);

  int ans = MAX_N;
  // pos1から始めるのが最適とは限らない．
  // pos1の周り，K個
  // [pos1 - K + 1, pos1 + K - 1] から探索
  for(int i = pos1-K+1; i <= pos1+K-1; ++i) {
    ans = min(ans, simulate_from(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640