akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define pb push_back
#define mp make_pair
#define ip pair<int, int>
#define F first
#define S second
#define fori(l, n) for(int i = l; i < n; i++)
#define forj(k, m) for(int j = k; j < m; j++)
#define revi(h) for(int i = h; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define PI 3.14159265358
#define debug(x) cout<<"DEBUGGING --- "<<x<<endl;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file freopen("output.txt", "w", stdout);
signed main(){
    fastio;
	//input_from_file; 
	//output_to_file;
    int n, k;
    cin>>n>>k;
    vector<int>H(n + 1);
    fori(1, n + 1) cin>>H[i];
    vector<int>DP(n + 1, 0);
    DP[1] = 0;
    fori(2, n + 1){
        DP[i] = INT_MAX;        
        for(int j = i - 1; j >= max((ll)1, i - k); j--) DP[i] = min(DP[i], DP[j] + abs(H[i] - H[j]));
    }
    cout<<DP[n]<<endl;    
} 

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

a = ord('a')
reprs = [('a', a)]
for i in range(1, n):
    tmprep = []
    for r, l in reprs:
        for j in range(l-a+2):
            tmprep.append((r+chr(a+j), max(l, a+j)))
    reprs = tmprep



for r, l in reprs:
    print(r)

Measured memory_bytes: 21592
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    string S; cin >> S;
    ll p = S.size();
    vi SR(0); vi SL(0);
    for(int i=0; i<p-1; i++){
        if(S[i]=='R'&&S[i+1]=='L'){SR.emplace_back(i);}
        else if(S[i]=='L'&&S[i+1]=='R'){SL.emplace_back(i);}
    }
    vector<int> res(p, 0);
    ll l = SR.size();
    for(int i=0; i<l; i++){
        int L, R;
        if(i == 0){
            L = SR[i] + 1;
        }
        else{L = SR[i] - SL[i-1];}
        if(i == l-1){
            R = p - SR[i] - 1;
        }
        else{R = SL[i] - SR[i];}
        ll LP, RP; LP = 0; RP = 0;
        if(L % 2 == 1){LP += (L+1)/2; RP += L/2;}
        else{LP += L/2; RP += L/2;}
        if(R % 2 == 1){LP += R/2; RP +=(R+1)/2;}
        else{LP += R/2; RP += R/2;}
        res[SR[i]] += LP;
        res[SR[i]+1] += RP;
    }
    for(int i=0; i<p; i++){
        cout << res[i] << " ";
    }
}

Measured memory_bytes: 1532
#include <stdio.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    long A, B, C, D;
    long real;
    long cdv;
    bool result = false;
    do {
        scanf("%ld", &A);
        scanf("%ld", &B);
        scanf("%ld", &C);
        scanf("%ld", &D);
        if ((1 <= A && A <= B && B <= pow(10,18.0)) && (1 <= C) && (D <= pow(10, 9.0))){
            result = true;
        }
    }while(result == false);
    long c = C;
    long d = D;
    do {
        real = d % c;
        cdv = c;
        d = c;
        c = real;
    }while(real != 0);

    long lcm = C * D / cdv;
    long bc = B / C;
    long bd = B / D;
    long bl = B / lcm;
    long ac = (A - 1) / C;
    long ad = (A - 1) / D;
    long al = (A - 1) / lcm;
    long want = B - (bc + bd -bl) - ((A -1) - (ac + ad -al));

    printf("%ld\n",want);
        return 0;
}

Measured memory_bytes: 128
c=lambda p,x:int(p*(100+x)/100)
def d(p,x):
  e=int(p*100/(100+x))
  for i in range(e,e+3):
    if int(i*(100+x)/100)==p:
      return i
  return 0

while 1:
  x,y,s=map(int,input().split())
  if not x and not y and not s:break
  m=([[c(d(i,x),y),c(d(s-i,x),y)] for i in range(1,s//2+1)])
  print(max(map(sum,m)))


Measured memory_bytes: 5700
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=1000005;
const ll SQN=330;
const ll LG=31;
const double PI=atan(1)*4;
using namespace std;

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

    ll k;
    cin >> k;
    ll rem=0;
    rep(i,1,MAX) {
    	ll r=(10*rem+7)%k;
    	if(r==0) ret(i);
    	rem=r;
    }
    ret(-1);


}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**8)
class SegTee:
    
    def __init__(self):
        self.arr=[0]*(4*n)
    def update(self,node,start,end,index,val):
        if index <start or index>end:
            return
        
        if start==end:
            #print(node,val)
            
            self.arr[node]=val
        else:
            mid=(start+end)//2
            self.update(2*node+1,start,mid,index,val)
            self.update(2*node+2,mid+1,end,index,val)
            self.arr[node]=max(self.arr[2*node+1],self.arr[2*node+2])
            
    def query(self,node,tl,tr,l,r):
        if tl>r or tr<l:
            return 0
        elif tl>=l and tr<=r:
            return self.arr[node]
        else:    
            mid=(tr+tl)//2
            p1=self.query(2*node+1,tl,mid,l,r)
            p2=self.query(2*node+2,mid+1,tr,l,r)
            return max(p1,p2)
    

n = int(raw_input())
hi = list(map(int,raw_input().split()))
co= list(map(int,raw_input().split()))
#print(hi)
#print(co)
segTree=SegTee()
dp=[0]*(n)
ans=0
for i in range(n):
  x=hi[i]
  y=segTree.query(0,0,n-1,0,x-1)
  dp[i]=y+co[i]
  ans=max(ans,dp[i])
  #print(dp[i])
  segTree.update(0,0,n-1,x-1,dp[i])
  #print(segTree.arr)
#print(dp)
print(segTree.query(0,0,n-1,0,n-1))  
      


Measured memory_bytes: 87416
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;




int main() {
	int N, K;
	vector<int> e[100000], v[100000]; /*eは辺のメモ、vは整数min + iが書かれている頂点はどこかのメモ*/
	int a[100000], vp[100000], P[100000];/*aは実際に書かれている整数のメモ*/
	int min;
	int i,j,k,v1,v2;

	scanf("%d", &N);

	for (i = 0; i < N - 1; i++) {
		scanf("%d %d", &v1, &v2);
		e[v1 - 1].push_back(v2 - 1);
		e[v2 - 1].push_back(v1 - 1);
	}

	for (i = 0; i < N; i++) {
		a[i] = -1;
	}

	scanf("%d", &K);
	min = 1000000;
	for (i = 0; i < K; i++) {
		scanf("%d %d", &vp[i], &P[i]);
		if (min > P[i]) { min = P[i]; }
	}

	for (i = 0; i < K; i++) {
		if (P[i] - min >= N) { printf("No\n"); return 0; }
		a[vp[i] - 1] = P[i];
		v[P[i] - min].push_back(vp[i] - 1);
	}

	for (i = 0; i < N; i++) {
		for (int j : v[i]) {/*整数min + iが書かれたすべての頂点jについて、*/
			for (int k : e[j]) {/*jと隣接するすべての頂点について、*/
				if (a[k] == -1) {
					a[k] = min + i + 1;
					v[i + 1].push_back(k);
				}
				else if ((a[k] != min + i + 1) && (a[k] != min +  i - 1)) {
					printf("No\n"); return 0;
				}
			}
		}
	}
	printf("Yes\n");
	for (i = 0; i < N; i++) {
		printf("%d\n", a[i]);
	}
	return 0;

}

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

int main (){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  int ans = 0;
  cin >> n  >> k;
  vector <int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < k; i++){
    ans += v[i];
  }
  cout << ans;
}



Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

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

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;
constexpr ll mod = 1e9 + 7;

int N = 200010;
ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
    return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

int main()
{
    inv[1] = 1;

    for (int i = 2; i <= N; ++i) {
        inv[i] = mod - (mod / i) * inv[mod % i] % mod;
    }

    fac[0] = fac_inv[0] = 1;

    for (int i = 1; i <= N; ++i) {
        fac[i] = (fac[i - 1] * i) % mod;
        fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
    }

    int H, W, A, B; cin >> H >> W >> A >> B;

    ll sum = 0;

    rep(i, H - A) {
        sum += C(i + B - 1, i) * C(W - B - 1 + (H - i - 1), H - i - 1) % mod;
        sum %= mod;
    }

    cout << sum << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    ll a[n];
    vector<ll> mp(mx,0);
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        mp[a[i]]--;
        bool valid=1;
        for(int j=1;(j*j)<=a[i];j++){
            if(a[i]%j==0){
                if(mp[j]>0){
                    valid=0;
                    break;
                }
                if(mp[a[i]/j]>0){
                    valid=0;
                    break;
                }
            }
        }
        if(valid) ans++;
        mp[a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12664
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
using namespace std;
typedef long long ll;
int n,tot,a[800001];
char s[500001];
void mul(int a[],int &n,int k){
//     a[n]a[n-1]...a[1]是长度为n(a[1]a[2]...a[n]才是n)的大数(ans)，求ans*k之后得到的各个位数的数字之和
//     tot保存的是之和，a[n]a[n-1]...a[1]是保留ans*k
    int p=0;
    tot=0;
    for(int i=1;i<=n;i++){
        p=a[i]*k+p;
        a[i]=p%10;
        tot+=a[i];
        p/=10;
    }
    if(p)a[++n]=p;
    tot+=p;
}
void add(int a[],int &n,int k){
    int p=0;//p是进位
    tot-=a[1];//tot保留的的到ans+k之后的数字各位数之和.a[n]a[n-1]..a[1]也就变成了ans+k
    a[1]+=k;
    p=a[1]/10;
    a[1]%=10;
    tot+=a[1];
    for(int i=2;i<=n;i++){
        tot-=a[i];
        a[i]+=p;
        p=a[i]/10;
        a[i]%=10;
        tot+=a[i];
        if(!p)break; //加法没有进位，
    }
    if(p)a[++n]=p;
    tot+=p;
}
int main(){
    scanf("%s",s);
    n=strlen(s);
    for(int i=1;i<=n;i++){
        a[i]=s[n-i]-'0';
    }
    mul(a,n,9);
    for(int i=1;i<=n;i++){
        add(a,n,9);//cout<<tot<<endl;
        if(tot%9==0&&i*9>=tot){
            printf("%d\n",i);
            break;
        }
          //  return printf("%d",i),0;
    }
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  int N;
  cin >> N;
  set<int> d;
  for (int i = 0; i < N; i++) { int tmp; cin >> tmp; d.insert(tmp); }
  cout << d.size() << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void go();
int main() {
#ifdef tokitsukaze
    freopen("TEST.txt", "r", stdin);
#endif
    go();
    return 0;
}

/*********************************  head  *********************************/


int n,a,m;

LL ans;
void go() {
    cin>>n>>m;
    if(n>9 ||m>9){
        puts("-1");
    }else{
        printf("%d\n",n*m);
    }
}


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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

vector<pair<ll, ll>> factorize(ll n) {
  vector<pair<ll, ll>> res;
  ll divof2 = 0;
  while(n % 2 == 0) {
    ++divof2;
    n >>= 1;
  }
  if(divof2) res.push_back({2, divof2});

  for(ll i = 3; i*i <= n; i+=2) {
    if(n % i) continue;
    ll ct = 0;
    while(n % i == 0) {
      ++ct;
      n /= i;
    }
    res.push_back({i, ct});
  }
  if(n != 1) res.push_back({n, 1});
  return res;
}

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

  ll a, b;
  cin >> a >> b;

  vector<pair<ll, ll>> ps = factorize(__gcd(a, b));
  cout << ps.size()+1;
  return 0;
}


Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n
s = n.to_s
if s[-1] == "2" || s[-1] == "4" || s[-1] == "5" || s[-1] == "7" || s[-1] == "9"
  puts "hon"
elsif s[-1] == "0" || s[-1] == "1" || s[-1] == "6" || s[-1] == "8"
  puts "pon"
else
  puts "bon"
end


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

int main(){
  string s;
  cin >> s;
  int first_A = 0;
  int last_Z = s.size() - 1;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'A'){
      first_A = i;
      break;
    }
  }
  for(int i = s.size() - 1; i > 0; i--){
    if(s.at(i) == 'Z'){
      last_Z = i;
      break;
    }
  }
  cout << last_Z - first_A + 1;
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    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 MOD = 998244353;
int N,A[MAXN];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
int gcd(int a,int b) {
    return b == 0 ? a : gcd(b,a % b);
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(A[i]);
    sort(A + 1,A + N + 1);
    int ans = 1;
    for(int i = 1 ; i <= N ; ++i) ans = mul(ans,gcd(A[i],i - 1));
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            continue
        else:
            print("DENIED")
            exit()
print("APPROVED")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i,n) for (int i=0; i< (n); ++i)
typedef pair<int, int> P;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> order[n];
  vector<pair<int, int>> city(m);
  for (int i=0; i<m; i++) {
    cin >> city[i].first >> city[i].second;
    order[city[i].first-1].push_back(city[i].second);
  }
  for (int i=0; i<n; i++) {
    sort(order[i].begin(), order[i].end());
  }
  
  for (int i=0; i<m; i++) {
    int prefercture = city[i].first-1;
    auto birthIter = lower_bound(order[prefercture].begin(), order[prefercture].end(), city[i].second);
    int birth = birthIter - order[prefercture].begin() + 1;
    printf("%06d%06d\n", prefercture+1, birth);
    //cout << prefercture+1 << " " << birth << endl;
  }
  return 0;
}


Measured memory_bytes: 7680
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=4040;
char a[N], b[N];
int lena, lenb;
int na[N][2], nb[N][2];
void parse(char* s, int& len, int nxt[N][2]){
  scanf("%s", s);
  len=strlen(s);
  int tnxt[2];
  tnxt[0]=tnxt[1]=len;
  nxt[len][0]=len;
  nxt[len][1]=len;
  for(int i=len-1; i>=0; i--){
    tnxt[s[i]-'0']=i;
    for(int j=0; j<2; j++)
      nxt[i][j]=tnxt[j];
  }
}
short dp[N][N];
bool tg[N][N];
int DP(int i, int j){
  i=min(i, lena);
  j=min(j, lenb);
  if(i>=lena and j>=lenb) return 1;
  if(tg[i][j]) return dp[i][j];
  int tdp=N;
  for(int d=0; d<2; d++){
    int ni=na[i][d];
    int nj=nb[j][d];
    if(ni>=lena and nj>=lenb)
      tdp=min(tdp, 1);
    else
      tdp=min(tdp, 1+DP(ni+1, nj+1));
  }
  tg[i][j]=true;
  return dp[i][j]=tdp;
}
void con(int i, int j){
  while(true){
    i=min(i, lena);
    j=min(j, lenb);
    if(i>=lena and j>=lenb){
      printf("0");
      return;
    }
    for(int d=0; d<2; d++){
      int ni=na[i][d];
      int nj=nb[j][d];
      if(ni>=lena and nj>=lenb){
        if(dp[i][j] == 1){
          printf("%d", d);
          return;
        }
      }else{
        if(1+DP(ni+1, nj+1) == dp[i][j]){
          printf("%d", d);
          i=ni+1;
          j=nj+1;
          break;
          //con(ni+1, nj+1);
          //return;
        }
      }
    }
  }
}
int main(){
  parse(a, lena, na);
  parse(b, lenb, nb);
  for(int i=lena; i>=0; i--)
    for(int j=lenb; j>=0; j--)
      DP(i, j);
  // int ans=DP(0, 0);
  // cout<<ans<<endl;
  con(0, 0);
  puts("");
}


Measured memory_bytes: 50644
INF = 10**18

N, M, P = map(int, input().split())
G = []
G1 = [[] for i in range(N)]
G2 = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    G.append((a, b, c-P))
D = [0]*N
for i in range(N):
    D[i] = -INF
D[0] = 0
for i in range(N):
    for j in range(M):
        fr, to, cost = G[j]
        if D[fr] != -INF and D[fr]+cost > D[to]:
            D[to] = D[fr]+cost
tmpAns = D[N-1]
for _ in range(N):
    for j in range(M):
        fr, to, cost = G[j]
        if D[fr] != -INF and D[fr]+cost > D[to]:
            D[to] = INF
            if to == N-1 and D[to] != tmpAns:
                print(-1)
                exit()
if D[N-1] < 0:
    print(0)
else:
    print(D[N-1])


Measured memory_bytes: 53224
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define MAX_V 10001
vector<pair<string,P> >vec;

struct edge { ll to, cost; };
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
	// greater<P>を指定することでfirstが小さい順に取り出せるようにする
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + MAX_V, INF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){	
	ll N, M;
	cin >> N >> M;
	vector<ll> a(M), b(M), c(M);
	rep(i, M) {
		cin >> a[i] >> b[i];
		rep(j, b[i]) {
			ll ic;
			cin >> ic;
			ic--;
			c[i] += 1 << ic;
		}
		rep(j, 1<<N) {
			if ((j|c[i]) != j) {
				edge e1 = {(j|c[i]),a[i]};
        		G[j].push_back(e1);
			}
		}
	}
	dijkstra(0);
	if (d[(2<<(N-1)) - 1] == INF) cout << "-1" << endl; else cout << d[(2<<(N-1)) - 1] << endl;
}


Measured memory_bytes: 71424
rule = ["I","V","X","L","C","D","M"]
val = [1,5,10,50,100,500,1000]
while True:
    try:
        nums = input()
        ans = val[rule.index(nums[0])]

        for i in range(1,len(nums)):
            ans += val[rule.index(nums[i])]
            if rule.index(nums[i]) > rule.index(nums[i-1]):
                ans -= (2*val[rule.index(nums[i-1])])

        print(ans)
    except EOFError: break

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

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

    bool flag = true;
    rep(i,n){
        if(a[i]%2 == 0){
            if(a[i]%3!=0 && a[i]%5!=0) flag = false;
        }
    }

    if(flag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

	return 0;
}

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

//http://agc005.contest.atcoder.jp/tasks/agc005_a
//AGC005-A-STring
class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("TSTTSS");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("SSTTST");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("TSSTTTSS");
            //4
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string X = InputList[0];

        int SCnt = 0;
        int RemoveCnt = 0;
        foreach (char EachChar in X) {
            if (EachChar == 'S') SCnt++;
            if (EachChar == 'T' && SCnt > 0) {
                RemoveCnt++;
                SCnt--;
            }
        }
        Console.WriteLine(X.Length - RemoveCnt * 2);
    }
}


Measured memory_bytes: 3416
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;

int main() {
  //
  cin >> N;
  string ans = "";

  ll mul = 26;
  ll rank = 1;
  while (N > mul) {
    N -= mul;
    mul *= 26LL;
    ++rank;
  }

  --N;

  while (N > 0) {
    char c = N % 26 + 'a';
    ans.push_back(c);
    N /= 26;
  }

  while (ans.size() < rank) {
    ans.push_back('a');
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 5010;
int Ws[maxn], Wt[maxn], ns = 0, nt = 0;
int vs[maxn], vt[maxn], n;
int get(int x)
{
	int sum = 0;
	int j = 1;
	for(int i = 1; i <= x; i ++)
	{
		if(j > nt)
			sum += n;
		else
			sum += Wt[j];
		j ++;
	}
	for(int i = 1; i <= ns; i ++)
	{
		if(j > nt)
			sum += n - Ws[i];
		else
		{
			sum += abs(Wt[j] - Ws[i]);
			j ++;
		}
	}
	for(; j <= nt; j ++)
		sum += abs(n - Wt[j]);
	return sum;
}
int go(int x)
{
	int sum = 0;
	int j = 1;
	for(int i = 1; i <= x; i ++)
	{
		if(i > ns)
			sum += n;
		else
			sum += Ws[i];
	}
	for(int i = x + 1; i <= ns; i ++)
	{
		if(j > nt)
			sum += n - Ws[i];
		else
		{
			sum += abs(Wt[j] - Ws[i]);
			j ++;
		}
	}
	for(; j <= nt; j ++)
		sum += n - Wt[j];
	return sum;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		char a;
		cin >> a;
		vs[i] = a - '0';
	}
	for(int i = 1; i <= n; i ++)
	{
		char a;
		cin >> a;
		vt[i] = a - '0';
	}
	if(n == 1)
	{
		cout << (vs[1] ^ vt[1]) << endl;
		return 0;
	}
	for(int i = 1; i < n; i ++)
	{
		if((vs[i] ^ vs[i + 1]) == 0)
		{
			ns ++;
			Ws[ns] = i;
		}
		if((vt[i] ^ vt[i + 1]) == 0)
		{
			nt ++;
			Wt[nt] = i;
		}
	}
	if(ns > nt)
	{
		for(int i = 1; i <= ns; i ++)
			swap(Ws[i], Wt[i]);
		swap(ns, nt);
	}
	/*
	cout << ns << " " << nt << endl;
	for(int i = 1; i <= ns; i ++)
		cout << Ws[i] << " " ;
	cout << endl;
	for(int i = 1; i <= nt; i ++)
		cout << Wt[i] << " " ;
	cout << endl;
	*/
	int asd = (vs[1] ^ vt[1]);
	//cout << asd << endl;
	int ans = maxn * maxn;
	for(int i = asd; i + ns <= nt * 2 + 3; i += 2)
		ans = min(ans, get(i));
	//cout << ans << endl;
	for(int i = asd; i <= nt * 2 + 3; i += 2)
		ans = min(ans, go(i));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


ll fac[10000],finv[10000],inv[10000];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<10000;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;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

mint dp[4005][4005];
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n, a, b, N = 2001;
    cin >> n;
    vector<pair<ll,ll> > v;
    for(int i=0;i<n;i++) {
    	cin >> a >> b;
    	dp[N - a][N - b] += 1;
    	v.push_back({a,b});
    }
    mint ans = 0;
    ll M = N * 2;
    for(int i=1;i<=M;i++){
    	for(int j=1;j<=M;j++){
    		dp[i][j] += dp[i-1][j] + dp[i][j-1];
    	}
    }
    for(auto& i:v){
    	ans += dp[i.first + N][i.second + N];
    	ans -= com( i.first * 2 + i.second * 2, i.first * 2);
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 131952
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,c;
    char b;
    cin >>a>>b>>c;
    if(b=='+')printa(a+c);
    else if(b=='-')printa(a-c);
    return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  double w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = w*h/2;
  printf("%lf ",ans);
  if(w/2 == x && h/2 == y) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

typedef long long ll;

const int N = 10005;

int n, m;
int Wight[10] = {0,2,5,5,4,5,6,3,7,6}, A[15];

vector<string> f(N,"-");

string Max(string a, string b)
{
    if (a.size() != b.size())
		return a.size() > b.size()? a : b;
    return a > b? a : b;
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++) 
		cin >> A[i];
    f[0] = "";
    for(int i = 0; i <= n; i++)
    {
    	if(f[i] != "-")
    	{
    		for(int j = 1; j <= m; j++)
    		{
    			if(i + Wight[A[j]] <= n)
    			{
            		f[i + Wight[A[j]]] = Max(f[i + Wight[A[j]]], f[i] + char(A[j] + '0'));
				}
			}	
		}
	}
	cout << f[n] << endl;
    return 0;
}

Measured memory_bytes: 43648
from collections import defaultdict
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 6)


@lru_cache(maxsize=None)
def rec(node):
    if len(graph[node]) == 0:
        return 0
    ans = 0
    for after in graph[node]:
        ans = max(ans, rec(after) + 1)
    return ans


n, m = map(int, input().split())
graph = defaultdict(list)

for i in range(m):
    x, y = map(int, input().split())
    graph[x].append(y)

ans = 0
for i in range(1, n + 1):
    ans = max(ans, rec(i))

print(ans)

Measured memory_bytes: 145640
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

char beet(char c){
  if (c == 'r') return 'p';
  if (c == 'p') return 's';
  else return 'r';
}

int main() {
  ll n, k, r, s, p;
  string str;
  cin >> n >> k >> r >> s >> p >> str;

  ll ans = 0;
  string hst = "";
  for (ll i = 0; i < n; i++) {
    if (i - k < 0 || hst[i - k] != beet(str[i])) {
      if (str[i] == 'r') {
        hst += 'p';
        ans += p;
      }
      if (str[i] == 's') {
        hst += 'r';
        ans += r;
      }
      if (str[i] == 'p') {
        ans += s;
        hst += 's';
      }
    } else{
      hst += 'x';
    }
  } // i
 
  cout << ans << endl;
  //cout << hst << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int n=s.size();
  if(s[0]=='0'||s[n-1]=='1'){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=0;i<(n+1)/2;i++){
    if(s[i]!=s[n-2-i]){
      cout<<-1<<endl;
      return 0;
    }
  }
  int now=0;
  for(int i=1;i<n;i++){
    if(s[i-1]=='1'){
      cout<<now+1<<" "<<i+1<<endl;
      now=i;
    }
    else{
      cout<<now+1<<" "<<i+1<<endl;
    }
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll a;
	cin >> a;
	long double b;
	cin >> b;
	cout << (ll)(a * b) << endl;

	return 0;
}

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

typedef long long ll;

int main() {
    ll N, ans = 0;
    cin >> N;
    for (ll K = 2; K * K <= N; K++) {
        ll n = N;
        while (n % K == 0) n /= K;
        if (n % K == 1) {
            ans++;
            //cout << " K=" << K;
        }
    }
    for (ll x = 1; x * x <= N; x++) {
        if ((N - 1) % x == 0) {
            ll k = (N - 1) / x;
            if (k > x) {
                ans++;
                //cout << " k=" << k;
            }
        }
    }
    //cout << "\n";
    cout << ans + 1 << "\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        String kurabe = t.substring(0,t.length()-1);
        if(s.equals(kurabe)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35480
#include<iostream>
#include<ios>
using namespace std;
constexpr int f(int a){
	return a?a%10+f(a/10):0;
}
template<int N>struct ans{
	int a[37][N+1];
	constexpr ans(){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=36;j++)a[j][i]=a[j][i-1];
			a[f(i)][i]+=i;
		}
	}
};
ans<10000>s;
main(){
	int ans=0,n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=a;i<=b;i++)ans+=s.a[i][n];
	printf("%d\n",ans);
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {

    int a[100000];
    int N;
    int res = 0;
    int nextNum;
    set<int> bottuns;

    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
    }

    nextNum = 1;
    bottuns.insert(nextNum);
    while(true){
        nextNum = a[nextNum];
        ++res;
        if(nextNum == 2){
            cout << res << endl;
            return 0;
        }
        if(bottuns.count(nextNum == 1) || res == N){
            break;
        }
        bottuns.insert(nextNum);
    }

    cout << -1 << endl;
    return 0;

}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ll long long
using namespace std;

vector<int>dp(100002, 1e9);

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i = 0; i < n; i++)cin>>a[i];
    dp[1] = 0;
    for(int i = 1; i <= n; i++){
        dp[i+1] = min(dp[i + 1],dp[i] + abs(a[i-1] - a[i]));
        dp[i+2] = min(dp[i + 2],dp[i] + abs(a[i-1] - a[i+1]));
    }
    cout<<dp[n]<<endl;
    return 0;
}



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

using namespace std;


#define mod        1000000007
#define ft         first
#define sd         second
#define pb         push_back
#define all(x)     x.begin(),x.end()
#define ll         long long int
#define db         long double
#define vbi        vector<bool> 
#define vlli       vector<long long int >
#define mp         make_pair
#define ms(x,v)    memset(x, v, sizeof x)
#define cnl        printf("\n");
#define fr(i,b)    for(ll i=0; i<=b; i++)
#define frr(i,b)   for(ll i=0;i<b;i++)
#define fb(i,b)    for(ll i=b-1; i>=0; i--)
#define PI         3.14159265
const int maxn=    100000;
ll i,j,k;
int main(){
  ll k,x; cin>>k>>x;
  vlli v;
  ll y=x-k+1;
  for(i=y;i<=x;i++){
  	cout<<i<<" ";
  }
 y=x+k-1;
 //cout<<y<<endl;
 for(i=x+1;i<=y;i++) cout<<i<<" ";



    return 0;
}

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

int main(){
  double n,t,a;
  cin >> n >> t >> a;
  vector<double> v(n,0),dif(n,0);
  r(i,n){
    cin >> v.at(i);
    dif.at(i)=abs(a-t+v.at(i)*0.006);
  }
  auto it=min_element(dif.begin(),dif.end());
  cout << distance(dif.begin(),it)+1<<endl;
}

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

int main(){
  int64_t X;
  cin>>X;
  int64_t A;
  int B,C;
  for(int i=1;i<121;i++){
    for(int j=-i;j<i;j++){
      A=i*i*i*i*i-j*j*j*j*j;
      if(X==A){
        B=i;
        C=j;
        break;
      }
    }
  }
  cout<<B<<" "<<C<<endl;
}

Measured memory_bytes: 3580
N = gets.to_i
A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = gets.to_i

min = [A, B, C, D, E].min
rest = N - min
rest_count = (rest % min == 0) ? rest / min : (rest / min) + 1
ans = rest <= 0 ? 5 : 5 + rest_count
puts ans


Measured memory_bytes: 1788
#include<stdio.h>

int main()
{
 int A,B,C;

 scanf("%d%d%d",&A,&B,&C);

 if(A==B)printf("%d\n",C);
 else if(A==C)printf("%d\n",B);
 else if(B==C)printf("%d\n",A);

 return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    //(l,r]
    ll l = 0, r = INF;
    while(r-l > 1){
        ll n = (l+r)/2;
        bool able = true;
        map<int, ll> mp;
        rep(i, N){
            if(i == 0 || A[i] > A[i-1]) continue;
            if(n == 1) {able = false; break;}
            mp[A[i]]++;
            map<int, ll>::iterator it = mp.find(A[i]);
            it++;
            while(it != mp.end()) it = mp.erase(it);
            int now = A[i];
            while(now > 0 && mp[now] == n){
                mp.erase(now--);
                mp[now]++;
            }
            if(now == 0) {able = false; break;}
        }
        if(able) r = n;
        else l = n;
    }
    cout << r << endl;
}

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

ll n,m,num;
vector<vector<ll> > adj;
ll dp[100005];

ll dfs(ll v){
    //vs[v]=1;
    //num=max(num,tmp);
    if(dp[v]==-1){
        ll a;
        //cout<<v<<" ";
        if(adj[v].size()>0){
            ll b,mx=0;
            for(ll x=0; x<adj[v].size(); x++){
                a=adj[v][x];
                b=1+dfs(a);
                mx=max(mx,b);
            }
            return dp[v]=mx;
        }
        return dp[v]=0;
    }
    return dp[v];
}

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 
    cin>>n>>m;
    ll a,b;
    adj.assign(n+1,vector<ll>());
    while(m--){
        cin>>a>>b;
        adj[a].push_back(b);
    }
    ll ans=0,tmp;
    for(ll x=1; x<=100001; x++)dp[x]=-1;
    for(ll x=1; x<=n; x++){
        //vs.assign(n+1,0);
        //num=0;
        tmp=dfs(x);
        //cout<<tmp<<endl<<endl;
        ans=max(ans,tmp);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8576
'use strict';

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

let line = lines[0],
	depth = 0,
	removed = 0;

const CODE_S = 83;

for (let c = 0; c < line.length; c++) {
	if (line.charCodeAt(c) === CODE_S) {
		depth++;
	} else {
		if (depth > 0) {
			depth--;
			removed += 2;
		}
	}
}

console.log(line.length - removed);

Measured memory_bytes: 15736
import sys

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


def resolve():
    n = int(input())
    H = list(map(int, input().split()))

    dp = [f_inf for _ in range(n)]
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])
    for i in range(2, n):
        dp[i] = min(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

    print(dp[-1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14484
#include<stdio.h>
#include<math.h>
 
int main() {
    double x[2], y[2], l;
    scanf("%lf %lf %lf %lf", &x[0], &y[0], &x[1], &y[1]);
    l = hypotl(x[1] - x[0], y[1] - y[0]);
    printf("%f\n", l);
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s == t) {
        cout << "No" << "\n";
        return 0;
    }
    if (s.length() <= t.length()) {
        int b = min(s.length(), t.length());
        for (int i = 0; i < b; i++) {
            if (s[i] == t[i])
                continue;
            if (s[i] < t[i]) {
                cout << "Yes" << "\n";
                return 0;
            }
            if (s[i] > t[i]) {
                cout << "No" << "\n";
                return 0;
            }
        }
        cout << "Yes" << "\n";
    }
    else {
        int b = min(s.length(), t.length());
        for (int i = 0; i < b; i++) {
            if (s[i] == t[i])
                continue;
            if (s[i] < t[i]) {
                cout << "Yes" << "\n";
                return 0;
            }
            if (s[i] > t[i]) {
                cout << "No" << "\n";
                return 0;
            }
        }
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <deque>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s;
    cin >> s;
    deque<char> d;
    for(char c : s){
        d.push_back(c);
    }
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x == 1){
            cnt++;
        }
        else{
            int y;
            cin >> y;
            char z;
            cin >> z;
            if(cnt % 2 == 0){
            if(y == 1)
            d.push_front(z);
            else
            d.push_back(z);
            }
            else{
                if(y == 2)
            d.push_front(z);
            else
            d.push_back(z);
            }
        }
    }
    if(cnt % 2 != 0)
    reverse(d.begin(), d.end());
    for(auto i : d){
        cout <<i;
    }
}









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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

vector<int> a, b;
string s, t;

int main(){
    cin >> s >> t;
    rep(i,s.size()) a.push_back(s[i]-'a');
    rep(i,t.size()) b.push_back(t[i]-'a');
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<int>());
    if (a < b) puts("Yes");
    else puts("No");
}
































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,A;
    cin>>X>>A;
    if(X>=A)cout<<10<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
from sys import stdin, stdout

N, K, C = map(int,stdin.readline().rstrip().split())
S = stdin.readline()



vec = []
rvec = []

i = 0
while i < N:
    if S[i] == 'o':
        vec.append(i)
        i += C
    i += 1

j = N - 1
while j >= 0:
    if S[j] == 'o':
        rvec.append(j)
        j -= C
    j -= 1


ans = []
for i in range(K):
    if vec[i] == rvec[K - i - 1]:
        stdout.write(str(vec[i] + 1) + '\n')
stdout.write('\n')


Measured memory_bytes: 25084
#include <iostream>
using namespace std;
int main(){
    string s;
    int count = 0;
    cin >> s;
    
    for(int i = 0; i < s.length() / 2; i++){
        if(s[i]  != s[s.length() - i - 1])    count++;
    }
    cout << count;
}

Measured memory_bytes: 256