akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>

using namespace std;



int main() {
	int n;
	cin >> n;
	int x = 0;
	for (int i = 0; i <= n; i++) {
		if ((int)(i * 1.08) == n) {
			x = i;
		}
	}
	if (x > 0) {
		cout << x << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    int n = s.size();
    string t;
    for(auto &i : s){
        if(t.size() && t.back() == 'S' && i == 'T'){
            t.pop_back();
            n -= 2;
        }
        else t += i;
    }
    cout << n << endl;
}


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

int main(void){
    int x,temp,output=0;
    int a=0,b=0;
    cin >> x;
    a = x / 500;
    temp = x - a*500;
    b = temp / 5;
    // cout << "a:" << a << endl;
    // cout << "b:" << b << endl;
    cout << a*1000 + b*5<<"\n";
    return 0;
}

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

const int INF = 0x3f3f3f3f;
const int MAXN = ( int ) 1e5;

int N, M;
vector< int > G[ MAXN ];
int dis[ MAXN ];
int vis[ MAXN ];
int deg[ MAXN ];

vector< int > ans;

int X;
void dfs( int u ){
  ans.emplace_back( u + 1 );
  for( int v : G[ u ] ){
    if( vis[ v ] == X ) continue;
    vis[ v ] = X;
    return dfs( v );
  }
}

signed main(){
srand( time( NULL ) );
  ios::sync_with_stdio( 0 );
  cin >> N >> M;
  for( int i = 0; i < M; ++i ){
    int A, B; cin >> A >> B;
    G[ A - 1 ].emplace_back( B - 1 );
    G[ B - 1 ].emplace_back( A - 1 );
    ++deg[ A - 1 ];
    ++deg[ B - 1 ];
  }
  vector< int > one;
  for( int i = 0; i < N; ++i ){
    if( deg[ i ] == 1 ){
      one.emplace_back( i );
    }
  }
  // assert( not one.empty() );
  for( X = 1; ; ++X ){
    ans.clear();
    int st;
    st = rand() % N;
    if( X & 1 ){
      queue< int > que;
      memset( dis, INF, sizeof( dis ) );
      dis[ st ] = 0;
      que.emplace( st );
      while( not que.empty() ){
        int u = que.front();
        que.pop();
        st = u;
        for( int v : G[ u ] ){
          if( dis[ v ] > dis[ u ] + 1 ){
            dis[ v ] = dis[ u ] + 1;
            que.emplace( v );
          }
        }
      }
    }
    vis[ st ] = X;
    dfs( st );
    bool ng = false;
    for( int v : G[ st ] ){
      if( vis[ v ] != X ){
        ng = true;
        break;
      }
    }
    for( int v : G[ ans.back() - 1 ] ){
      if( vis[ v ] != X ){
        ng = true;
        break;
      }
    }
    if( not ng ) break;
  }
  cout << ans.size() << endl;
  for( int i = 0; i < ans.size(); ++i ){
    cout << ans[ i ] << " \n"[ i + 1 == ans.size() ];
  }
  return 0;
}


Measured memory_bytes: 11128
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,x = map(int,input().split())
a = [int(i) for i in input().split()]
part_sum = [0 for i in range(N)]

ans = 0
if a[0] > x:
    ans += a[0]-x
    a[0] = x
left = a[0]
for i in range(1,N):
    if left + a[i] > x:
        ans += left + a[i] - x
        a[i] = x - left
    left = a[i]


print(ans)

"""
1 6 1 2 0 4
1 0 1 0 0 1
0 1 0 1 0 1


"""


Measured memory_bytes: 16592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <cstring>
using namespace std;
char s[5];
int f1, f2, tmp;
int main() {
    cin >> s;
    tmp = (s[0] - '0') * 10 + s[1] - '0';
    if (tmp <= 12 && tmp > 0) f1 = 1;
    tmp = (s[2] - '0') * 10 + s[3] - '0';
    if (tmp <= 12 && tmp > 0) f2 = 1;
    if (f1 == 1 && f2 == 1) cout << "AMBIGUOUS";
    else {
        if (f1 == 1) cout << "MMYY";
        if (f2 == 1) cout << "YYMM";
        if (f1 == 0 && f2 == 0) cout << "NA";
    }
    return 0;
}

Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))
cont = 0
cont_list =[]

for a in A:
    if a % 2 != 0:
      cont_list.append(cont)
      break
    else:
        while a % 2==0:
            a //= 2
            cont += 1
        cont_list.append(cont)
        cont=0

print(min(cont_list))

Measured memory_bytes: 3060
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

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

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  int n,k;cin>>n>>k;
  vector<double> p(n);
  rep(i, n){
    cin>>p[i];
    p[i]++;
  }

  rep(i, 1, n) p[i] += p[i-1];

  double ans = p[k-1];
  rep(l, 0, n-k){
    chmax(ans, p[l+k]-p[l]);
  }
  // cout << ans/2 << endl;
  printf("%.10f", ans/2);

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

string island[12];

void dfs( int i , int j ){

  island[i][j] = '0';

  if( i - 1 >= 0 && island[i-1][j] == '1' ){
    dfs( i - 1 , j );
  }
  if( j - 1 >= 0 && island[i][j-1] == '1'){
    dfs( i , j - 1 );
  }
  if( i + 1 < 12 && island[i+1][j] == '1'){
    dfs( i + 1 , j );
  }
  if( j + 1 < 12 && island[i][j+1] == '1'){
    dfs( i , j + 1 );
  }
}

int main(void){

  while(1){
    
    for( int i = 0 ; i < 12 ; i++ ){
      if(cin >> island[i]);
      else return 0;
    }

    int cnt = 0;
    for( int i = 0 ; i < 12 ; i++ ){
      for( int j = 0 ; j < 12 ; j++ ){
	if( island[i][j] == '1' ){
	  cnt++;
	  dfs( i , j );
	}
      } 
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
n, m, c = map(int, input().split())
blist = list(map(int, input().split()))
ans = 0
for _ in range(n):
  alist = list(map(int, input().split()))
  if sum([a*b for a, b in zip(alist, blist)]) + c > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3060
MOD = pow(10,9) + 7
H, W = map(int,raw_input().split())

grid = [[0]*W for h in range(H)]
grid[0][0] = 1

for h in range(H) :  
  row = raw_input()

  for w in range(W) :
    if row[w] == '#' : continue
    if h > 0 : grid[h][w] += grid[h-1][w]
    if w > 0 : grid[h][w] += grid[h][w-1]
    grid[h][w] %= MOD
  
print grid[-1][-1] % MOD

Measured memory_bytes: 40172
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

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

signed main(){
    int N,Ans=INF;
    cin >> N;
    ZREP(i,N){
        Ans=min(Ans,sum(i)+sum(N-i));
        //cout <<i << " "<< N-i << " "<< sum(i)+sum(N-i) << endl;
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

ranks = [False for i in range(8)]
highs = 0
n = int(input())
inps = [int(i) for i in input().split()]
highs = len([i for i in inps if i > 3199])
inps = [i for i in inps if i <= 3199]
for i in inps:
    if i >= 1 and i <= 399:
        ranks[0] = True
    elif i >= 400 and i <= 799:
        ranks[1] = True
    elif i >= 800 and i <= 1199:
        ranks[2] = True
    elif i >= 1200 and i <= 1599:
        ranks[3] = True
    elif i >= 1600 and i <= 1999:
        ranks[4] = True
    elif i >= 2000 and i <= 2399:
        ranks[5] = True
    elif i >= 2400 and i <= 2799:
        ranks[6] = True
    elif i >= 2800 and i <= 3199:
        ranks[7] = True
lows = len([i for i in ranks if i == True])

minimum = max(lows, 1)
maximum = lows + highs

print(minimum, maximum)


Measured memory_bytes: 3064
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main()
{
    // Input
    int n, m, x;
    cin >> n >> m >> x;

    int c[n];
    int a[n][m];    // !!! not a[n][n] but a[n][m] !!!

    rep(i, n) {
        cin >> c[i];

        rep(j, m) {
            cin >> a[i][j];
        }
    }

    // rep(i, n) {
    //     rep(j, m) {
    //         cout << "rep i: " << i << "  rep j: " << j << endl;
    //         cout << a[i][j] << endl;
    //     }
    // }

    int ans = INF;

    rep(i, 1 << n) { // i = 0 - 2^n
        // cout << endl;
        // cout << "rep i: " << i << endl;

        int cost = 0;
        vector<int> d(m, 0);

        rep(j, n) {
            if (i >> j & 1) {
                cost += c[j];

                rep(k, m) {
                    d[k] += a[j][k];
                    // cout << "rep j: " << j << "  rep k: " << k << endl;
                    // cout << "a[j][k]: " << a[j][k] << endl;
                    // cout << "d[k]: " << d[k] << endl;
                }
            }
        }
        bool isOk = true;
        for (auto delem : d) {
            // cout << "delem: " << delem << endl;
            if (delem < x) {
                isOk = false;
            }
        }
        if (isOk) {
            ans = min(ans, cost);
        }
    }

    if (ans == INF) {
        cout << -1 <<endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int count=0;
    for(int i=0;i<n/2;i++){
        if(s[i]=='w'&&s[n-1-i]!='w')count++;
        if(s[i]=='i'&&s[n-1-i]!='i')count++;
        if(s[i]=='('&&s[n-1-i]!=')')count++;
        if(s[i]==')'&&s[n-1-i]!='(')count++;;
    }
    if(n%2==1&&(s[n/2]=='('||s[n/2]==')'))count++;
    cout << count << endl;
}


Measured memory_bytes: 3208
use proconio::input;
use std::collections::BinaryHeap;

fn main()
{
    input! {
    n:i32,
    m:i32,
    a:[i64;n],
    b:[(i64,i64);m],
    }

    let mut q = BinaryHeap::new();
    for i in a {
        q.push((i, 1));
    }

    for (x, y) in b {
        q.push((y, x));
    }

    let mut ans: i64 = 0;
    for _ in 0..n {
        let (x, y) = q.pop().unwrap();
        ans += x;
        if y > 1 {
            q.push((x, y - 1));
        }
    }
    println!("{}", ans);
}

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

int main () {
    string S;
    cin >> S;
    int res = 0;
    int ans = 0;
    int tmp = 1;
    int chk[2019] = {};    
    chk[0] = 1;

    for(int i = S.size()-1 ;i >= 0 ;i-- ){
        res = (res + (S[i] - '0') * tmp) % 2019;
        tmp = (10 * tmp) % 2019;
        ans += chk[res];
        chk[res]++;
    }

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

Measured memory_bytes: 3736
import 'dart:io';

void main(List<String> arguments) {
  final k = int.parse(stdin.readLineSync());
  final s = stdin.readLineSync();
  print(getOutput(k, s));
}

String getOutput(int k, String s) {
  if (s.length <= k) {
    return s;
  } else {
    return s.substring(0, k) + '...';
  }
}


Measured memory_bytes: 13132
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
total=0
for i in range(n):
  total+=b[a[i]-1]
  if i<n-1:
    if a[i+1]-a[i]==1:
      total+=c[a[i]-1]
print(total)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


// 素因数分解O(√n)--------------------------------------------
ll prime_factor(ll n){
  ll res = 0;
  for (ll i=2; i*i<=n; i++){
    if (n%i==0) res++;
    while (n%i==0) n/=i;
  }
  if (n!=1) res++;
  return res;
}

int main() {
  ll a,b; cin >>a >>b;
  ll g = gcd(a, b);
  // gを素因数分解して素因数の数+1が答え
  ll res = 1 + prime_factor(g);
  cout <<res <<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int C[102][102];
 
void meiro(int W,int H,int c){
  if(C[W][H]!=c){
    return;
  }
 
  C[W][H] = -1;
 
  meiro(W-1,H  ,c);
  meiro(W  ,H+1,c);
  meiro(W+1,H  ,c);
  meiro(W  ,H-1,c);
}
 
int main(){
  while(1){
    int w,h;
    cin >> w >> h;
    if(w==0 && h==0){
      break;
    }
 
    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
        C[i][j] = 10;
      }
    }
 
    int xs,ys,xg,yg;
    cin >> xs >> ys >> xg >> yg;
 
    int n;
    cin >> n;
 
    int c,d,x,y;
    for(int i=0;i<n;i++){
      cin >> c >> d >> x >> y;
 
      if(d==0){
        for(int j=x;j<x+4;j++){
          for(int k=y;k<y+2;k++){
            C[j][k]=c;
          }
        }
      }else{
        for(int j=x;j<x+2;j++){
          for(int k=y;k<y+4;k++){
            C[j][k]=c;
          }
        }
      }
    }
 
    meiro(xs,ys,C[xs][ys]);
 
    if(C[xg][yg] == -1){
      cout << "OK" << endl;
    }else{
      cout << "NG" << endl;
    }
  }
 
  return 0;
}


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

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

  vector<int> vec(N);
  ;for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end()); 
 
  int count = 1;
  for (int i = 0; i < N-1; i++) {
    if (vec.at(i) < vec.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
}

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

int main()
{
 int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(auto &i:b) cin>>i;
  int ans=0;
  while(n--)
  {
    vector<int> a(m);
    int temp=c;
    for(int i=0;i<m;i++) {
      cin>>a[i];
      temp+=a[i]*b[i];
    }
    if(temp>0)
      ans++;
      
  }
  cout<<ans<<"\n";
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
int n, T;
int util[3010], mins[3010]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
int dp[3010][3010] = {0}; // テーブルの初期値はすべて 0 にしておきます

// 復元用テーブル
int prev_w[3010][3010];

int main() {
    // 入力受け取り
    cin >> n >> T;
    map<pair<int,int>,int>stock;
    for (int i = 0; i < n; ++i){

     cin >> mins[i] >> util[i];
     stock[make_pair(util[i],mins[i])]++;
    }

    // DPループ
    for (int i = 0; i < n; ++i) {
        for (int t = 0; t < T; ++t) {

            // i 番目の品物を選ぶ場合を考える
            if (t >= mins[i]) {
                if (dp[i+1][t] < dp[i][t-mins[i]] + util[i]) {
                    dp[i+1][t] = dp[i][t-mins[i]] + util[i];
                    prev_w[i+1][t] = t - mins[i];
                }
            }

            // i 番目の品物を選ばない場合を考える
            if (dp[i+1][t] < dp[i][t]) {
                dp[i+1][t] = dp[i][t];
                prev_w[i+1][t] = t;
            }
        }
    }

    // 最適値の出力
    //cout << dp[n][T] << endl;
    int ans=dp[n][T-1];

    // 復元
    //cout << "Selected items are..." << endl;
    int cur_w = T-1;
    int time=0;
    for (int i = n-1; i >= 0; --i) {
        if (prev_w[i+1][cur_w] == cur_w - mins[i]) {
            stock[make_pair(util[i],mins[i])]--; 
            time+=mins[i];
        }
        cur_w = prev_w[i+1][cur_w];
    }
    int add=0;
    rep(i,n){
        if(stock[make_pair(util[i],mins[i])]>0){
            add=max(add,util[i]);
        }
    }
   // cout<<" "<<time<<endl;
    if(time<T){
        ans+=add;
    }
    cout<<ans<<endl;
}

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

int solve(int i, int m, int n, int A[])
{
	if(m==0) return 1;
	if(i>=n) return 0;
	if(solve(i+1,m,n,A)==1 || solve(i+1,m-A[i],n,A)==1) return 1;
	else return 0;
}

int main()
{
	int i,n,A[20],q,m;
	
	scanf("%d",&n);
	for(i=0;i<=n-1;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<=q-1;i++)
	{
		scanf("%d",&m);
		if(solve(0,m,n,A)==1) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<algorithm> 

#include <sstream>
#include <bitset> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

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

    string s[101];

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

    for(int i = 1 ; i < n ; i++){
        for(int j=n-1 ; j>=i ; j--){
            if(s[j]<s[j-1]){
                string temp = s[j-1];
                s[j-1] = s[j];
                s[j] = temp;
            }
        }
    }

    for(int i = 0 ; i < n ; i++){
        cout << s[i] ;
    }
    cout << endl;
} 

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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;

int main(){
  int n; cin >> n;
  ll ans=0;

  for(int i=1;i<=n;i++){
      if(!(i%3==0 || i%5==0)){
        ans+=i;
      }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll A, B, K;

int main() {
  scanf("%lld %lld %lld", &A, &B, &K);

  for(ll i = A; i <= B; i++) {
    if (i < A + K ||  i > B - K) printf("%lld\n", i);
  }
}


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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

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

    ll cur=100;
    ll x;
    cin >> x;

    ll ans=0;
    while (cur<x) {
        cur+=cur/100;
        ++ans;
    }

    cout << ans;

    return 0;
}


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

int main()
{
  int64_t n, k, ans = 0;
  cin >> n >> k;
  if (abs(n - k) >= n)
    ans = n;
  else
  {
    if (n % k == 0)
      ans = 0;
    else
    {
      n = n % k;
      while (n > abs(n-k))
      {
        n = abs(n-k);
      }
      ans = n;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
typedef struct{
    double x,y;
} Point;
 

int koch(int n, Point p1, Point p2){

    Point s,t,u;
    double degree = M_PI / 3;

    if(n == 0)
    {
      printf("%.8f %.8f\n", p2.x, p2.y);
      return;
    }

    s.x = (2 * p1.x + 1 * p2.x) / 3.0;
    s.y = (2 * p1.y + 1 * p2.y) / 3.0;
    t.x = (1 * p1.x + 2 * p2.x) / 3.0;
    t.y = (1 * p1.y + 2 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(degree) - (t.y - s.y) * sin(degree) + s.x;
    u.y = (t.x - s.x) * sin(degree) + (t.y - s.y) * cos(degree) + s.y;

    koch(n-1,p1,s);  
    koch(n-1,s,u);
    koch(n-1,u,t);    
    koch(n-1,t,p2);
}
 
 
int main(){
    int n;
    Point p1,p2;
     
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;
     
    scanf("%d",&n);

    printf("%.8f %.8f\n",p1.x,p1.y);
    koch(n,p1,p2);
     
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define M 100000007
typedef pair<int,int> P;
int main(void){
	int n,m,k;
	while(1){
		cin>>n>>m;
		if(n==0)break;
		vector<P> cost[m+1],time[m+1];
		for(int i=0;i<n;i++){
			int a,b,c,t;
			cin>>a>>b>>c>>t;
			cost[a].push_back(P(b,c)); cost[b].push_back(P(a,c));
			time[a].push_back(P(b,t)); time[b].push_back(P(a,t));
		}
		cin>>k;
		for(int i=0;i<k;i++){
			int s,g,f;
			int leng[m+1];
			priority_queue<P,vector<P>,greater<P> > que;
			fill(leng,leng+m+1,M);
			cin>>s>>g>>f;
			leng[s]=0;
			que.push(P(0,s));
			if(f==0){
				while(!que.empty()){
					P p=que.top(); que.pop();
					int v=p.second;
					if(leng[v]<p.first) continue;
					for(int j=0;j<cost[v].size();j++){
						P x=cost[v][j];
						if(leng[x.first]>leng[v]+x.second){
							leng[x.first]=leng[v]+x.second;
							que.push(P(leng[x.first],x.first));
						}
					}
				}
				cout<<leng[g]<<endl;
			}else{
				while(!que.empty()){
					P p=que.top(); que.pop();
					int v=p.second;
					if(leng[v]<p.first) continue;
					for(int j=0;j<time[v].size();j++){
						P x=time[v][j];
						if(leng[x.first]>leng[v]+x.second){
							leng[x.first]=leng[v]+x.second;
							que.push(P(leng[x.first],x.first));
						}
					}
				}
				cout<<leng[g]<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3172
#include <iostream>
static void p(int *a, int n) {
    for (int i = 0; i < n; ++i) {
        std::cout << ((i != 0) ? " " : "") << a[i];
    }
    std::cout << std::endl;
}
static void isort(int *a, int n) {
    p(a, n);
    for (int i = 1; i < n; ++i) {
        int v = a[i];
        int j = i - 1;
        for (; j >= 0 && a[j] > v; --j) {
            a[j + 1] = a[j];
        }
        a[j + 1] = v;
        p(a, n);
    }
}
int main() {
    int n, a[1001];
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }
    isort(a, n);
}



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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}


template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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




int main(){

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

    string s;
    cin >> s;

    ll cnt=0;

    rep(i, s.size()){
        if(s[i] == '1'){
            ++cnt;
        }
    }

    ppp(cnt);


    return 0;



}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a=0; 
  char s[3],t[3];
   scanf("%s", s);
   scanf("%s", t);
   for(int i=0;i<3;i++){
	if(s[i]==t[i]){
      a++;
   	}
   }
 
  	printf("%d", a);
	return 0;
 
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void) {
    int i;
    int x, y;
    int tmp;
    while(1) {
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) {
            break;
        }

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

    return 0;
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = input()
    ws = S.split("W")
    w_cnt = 0
    bs = S.split("B")
    b_cnt = 0
    
    flg = True
    for i in ws:
        if i != "":
            flg = False
            w_cnt += 1
            
    if flg == True:
        print(0)
        sys.exit()
        
    flg = True
    for i in bs:
        if i != "":
            flg = False
            b_cnt += 1
    
    if flg == True:
        print(0)
        sys.exit()
        
    ans = (b_cnt + w_cnt) - 1
    print(ans)
    
    
if __name__ == "__main__":
	main()


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> cell(h + 2);
  string head, bottom;

  for (int i = 0; i < w + 2; i++) {
    head += '.';
    bottom += '.';
  }
  
  cell.at(0) = head;
  cell.at(h + 1) = bottom;

  for (int i = 1; i < h + 1; i++) {
    string s;
    cin >> s;
    cell.at(i) = '.' + s + '.';
  }

  for (int i = 1; i < h + 1; i++) {

    for (int j = 1; j < w + 1; j++) {
      int bom = 0;
      if (cell.at(i).at(j) == '.') {
        if (cell.at(i - 1).at(j - 1) == '#') bom++;
        if (cell.at(i - 1).at(j) == '#') bom++;
        if (cell.at(i - 1).at(j + 1) == '#') bom++;
        if (cell.at(i).at(j - 1) == '#') bom++;
        if (cell.at(i).at(j + 1) == '#') bom++;
        if (cell.at(i + 1).at(j - 1) == '#') bom++;
        if (cell.at(i + 1).at(j) == '#') bom++;
        if (cell.at(i + 1).at(j + 1) == '#') bom++;
        char bomc = '0' + bom;
        cell.at(i).at(j) = bomc;
      }
    }
    cout << cell.at(i).substr(1, cell.at(i).size() - 2) << endl;
  }
}

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

int main(){
    int a[5];   for(int i=0;i<5;i++)cin>>a[i];

    int min=9;
    for(int i=0;i<5;i++){
        if(a[i]%10>0 && a[i]%10<=min)min=a[i]%10;
    }

    for(int i=0;i<5;i++){
        if(a[i]%10==min){
            min=11;
        }
        else{
            while(a[i]%10!=0)a[i]++;
            }
    }
    int sum=0;
    for(int i=0;i<5;i++){
        sum+=a[i];
    }

    cout<<sum<<endl;



    return 0;
}


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

int N, M;
char s[128][12], t[128][12];

int main(void) {
	int i, j;
	int tamurayukari = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%11s", s[i]) != 1) return 1;
	}
	if (scanf("%d", &M) != 1) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%11s", t[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int horieyui = 0;
		for (j = 0; j < N; j++) {
			if (strcmp(s[i], s[j]) == 0) horieyui++;
		}
		for (j = 0; j < M; j++) {
			if (strcmp(s[i], t[j]) == 0) horieyui--;
		}
		if (horieyui > tamurayukari) tamurayukari = horieyui;
	}
	printf("%d\n", tamurayukari);
	return 0;
}


Measured memory_bytes: 128
n,x = gets.split.map(&:to_i)
ar = []
ctr = 0
n.times do
  ar << gets.to_i
end

ar.each do |v|
  x -= v
  ctr += 1
end

min = ar.min
while x >= min
  x -= min
  ctr += 1
end

puts ctr


Measured memory_bytes: 1788
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d%d", &a,&b);
	int sum = 0;
	int digit = 1;
	if (b < 10)
		digit = 10;
	if (b > 9 && b < 100)
		digit = 100;
	if (b > 99)
		digit = 1000;
	sum += digit * a;
	sum += b;
	int i = 1;
	int count = 0;
	while (i <= sum)
	{
		if (i % 2)
		{
			sum -= i;
			count++;
		}
		i++;
	}
	if (sum == 0)
		printf("Yes");
	else
		printf("No");
	return (0);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

#define maxn 100 + 5
#define max_sqrt_k 32000
#define mod 1000000007

int dp[2][max_sqrt_k][2], n, k, sqrt_k, i, j, t, ret, pref, sum0, sum1, count_lr[max_sqrt_k], le, ri, l, p;

void upd (int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int main (int argc, char * const argv[]) {
    scanf("%d %d", &k, &n);
    while (sqrt_k * sqrt_k < k) ++sqrt_k;
    for(i = 1; i <= sqrt_k; i++) dp[1][i][0] = 1;
    for(i = 1; i < sqrt_k; i++) {
        le = k / (i + 1) + 1;
        ri = k / i;
        if (ri <= sqrt_k) continue;
        le = max(le, sqrt_k + 1);
        count_lr[i] = ri - le + 1;
    }
    for(i = 1; i < sqrt_k; i++) dp[1][i][1] = count_lr[i];
    l = 1;
    for(i = 2; i <= n; i++) {
        p = l;
        l ^= 1;
        sum0 = sum1 = 0;
        for(j = 1; j <= sqrt_k; j++) {
            upd(sum0, dp[p][j][0]);
            upd(sum1, dp[p][j][1]);
        }
        t = sqrt_k;
        for(j = 1; j <= sqrt_k; j++) {
            while (j * t > k) upd(sum0, mod - dp[p][t--][0]);
            dp[l][j][0] = sum1 + sum0;
            if (dp[l][j][0] >= mod) dp[l][j][0] -= mod;
            upd(sum1, mod - dp[p][j][1]);
        }
        pref = 0;
        for(j = 1; j < sqrt_k; j++) {
            upd(pref, dp[p][j][0]);
            dp[l][j][1] = (count_lr[j] * 1LL * pref) % mod;
        }
    }
    for(j = 1; j <= sqrt_k; j++) {
        upd(ret, dp[l][j][0]);
        upd(ret, dp[l][j][1]);
    }
    printf("%d\n", ret);
    return 0;
}

Measured memory_bytes: 896
if true then
  fh=STDIN
else
  fh=open("in0013.txt")
end

stack=[]
out = []
while fh.gets do
  i=$_.chomp.to_i
  if i==0 then
    abort("stack empty") if stack.length==0
    out.push(stack.pop)
  else
    stack.push(i)
  end
end

puts out
fh.close

Measured memory_bytes: 8700
#include<iostream>
using namespace std;
int main(){
	double A;
	double B;
	scanf("%lf",&A);
	scanf("%lf",&B);
	if(A>=1&&B>=1){
		if(A>B)
	cout<<"GREATER";
	else if(B>A)
	cout<<"LESS";
	else if(A==B)
	cout<<"EQUAL";
	}
	else
	cout<<"Wrong";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastio;
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) > abs(x - b))
        cout << "B\n";
    else
        cout << "A\n";
}

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

struct Node{
   int key;
   Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
   Node *y=NIL;
   Node *x=root;
   Node *z=new Node;

   z->key=k;
   z->left=NIL;
   z->right=NIL;

   while(x!=NIL){
      y=x;
      if(z->key < x->key) x=x->left;
      else x=x->right;
   }
   
   z->parent=y;
   if(y==NIL) root=z;
   else{
      if(z->key<y->key) y->left=z;
      else y->right=z;
   }
}

void inorder(Node *u){
   if(u==NIL) return;
   inorder(u->left);
   cout << " " << u->key;
   inorder(u->right);
}

void preorder(Node *u){
   if(u==NIL) return;
   cout << " " << u->key;
   preorder(u->left);
   preorder(u->right);
}

int main(){
   int n, x;
   string com;
   cin >> n;

   for(int i=0; i<n; i++){
      cin >> com;
      if(com=="insert"){
         cin >> x;
         insert(x);
      }
      else{
         inorder(root);
         cout << endl;
         preorder(root);
         cout << endl;
      }
   }

   return 0;
}


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

using namespace std;

const long long int MOD=1e9+7;

long long dp[14][100009];

int main(){
    string s;
    cin >> s;
    int keta=1;
    for(int i=0;i<s.length();i++){
        char c=s[s.length()-1-i];
        if(c=='?'){
            if(i==0){
                for(int k=0;k<=9;k++){
                    dp[k][i]=1;
                }
            }
            else{
                for(int j=0;j<=9;j++){
                    for(int k=0;k<=12;k++){
                        int now=(keta*j+k)%13;
                        dp[now][i] = (dp[now][i] + dp[k][i-1])%MOD;
                    }
                }
            }
        }
        else{
            int tmp_i = int(c)-48;
            if(i==0){
                dp[tmp_i][i]=1;
            }
            else{
                for(int k=0;k<=12;k++){
                    int now=(keta*tmp_i+k)%13;
                    dp[now][i] = (dp[now][i]+ dp[k][i-1])%MOD;
                }
            }
        }
        keta = (keta*10)%13;
    }
    cout << dp[5][s.length()-1] << endl;
}

Measured memory_bytes: 10752
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    if n == k:
        return 1
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

mod = 10**9+7
N, K = map(int,input().split())
for i in range(1,K+1):
    if (N-K+1) < i:
        print(0)
        continue
    # 白部分を分割する
    pt_base = comb(N-K+1,i,mod)
    #分割部分に1個以上ものを入れる
    # 任意に入れれるものの個数
    ct = K - i
    # あとはランダム
    pt = comb(K-1 ,i-1  , mod)
    res = ((pt_base % mod) * (pt % mod)) % mod 
    print(res)

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int x,y;
    cin >> x >> y;
    cout << x/y+(x%y > 0);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <string.h>
#define F first
#define S second
#define MP make_pair
#define int long long
#define INF long(1e18)
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;


int n, m, k, s, pp, q, ans[100001];
int dead[100001];
vector<int> road[100001], root;
void bfs(int sta)
{
  queue<P> que;
  que.push(MP(sta, 0));
  dead[sta] = -1;
  while(!que.empty())
  {
    P p = que.front();
    que.pop();
    if(p.S == s) continue;
    for(int i = 0; i < road[p.F].size(); i++)
    {
      if(!dead[road[p.F][i]] || dead[road[p.F][i]] > p.S + 1)
      {
        que.push(MP(road[p.F][i], p.S + 1));
        dead[road[p.F][i]] = p.S + 1;
      }
    }
  }
}
void dijkstra(){
  priority_queue<P> pq;
  pq.push(MP(0, 1));
  ans[1] = 0;
  while(!pq.empty())
  {
    P p = pq.top();
    pq.pop();
    for(int i = 0; i < road[p.S].size(); i++)
    {
      if(dead[road[p.S][i]] == -1) continue;
      if(!dead[road[p.S][i]] && ans[road[p.S][i]] < p.F - pp)
      {
        pq.push(MP(p.F - pp, road[p.S][i]));
        ans[road[p.S][i]] = p.F - pp;
      }
      else if(ans[road[p.S][i]] < p.F - q){
        pq.push(MP(p.F - q, road[p.S][i]));
        ans[road[p.S][i]] = p.F - q;
      }
    }
  }
}
signed main()
{
  cin >> n >> m >> k >> s >> pp >> q;
  for(int i = 0; i < k; i++)
  {
    int a;
    cin >> a;
    root.push_back(a);
  }
  for(int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    road[a].push_back(b);
    road[b].push_back(a);
  }
  for(int i = 0; i < k; i++)
  {
    bfs(root[i]);
  }
  fill(ans, ans + n + 1, -INF);
  dijkstra();
  if(!dead[n])
    cout << -ans[n] - pp << endl;
  else
    cout << -ans[n] - q <<endl;
}

Measured memory_bytes: 13452
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<ll> a(n), b(n);
    vector<T> sum(n);
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
        sum[i]=T(a[i]+b[i], a[i], b[i]);
    }

    sort(sum.begin(), sum.end(), greater<T>());

    ll asum=0, bsum=0;
    for(int i=0; i<n; i++){
        ll x, y, z;
        tie(x, y, z)=sum[i];
        if(i%2==0) asum+=y;
        else bsum+=z;
    }
    cout << asum-bsum << endl;
}


Measured memory_bytes: 4096
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  long a, b, c, x, y; rd(a, b, c, x, y);

  if(a+b<c*2){
    writeln(x*a+y*b);
  }else{
    auto z=min(x, y),
         ret=z*c*2;
    x-=z; y-=z;
    // writeln(ret);
    if(x>0){
      ret+=x*min(a, c*2);
    }else if(y>0){
      ret+=y*min(b, c*2);      
    }
    writeln(ret);
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


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

int main() {
  string str[3];
  while(1) {

    for(int i=0;i<3;i++) {
      getline(cin,str[i]);
      if(cin.eof()) return 0;
      //      cout << str[i] << endl;
    }

    bool r = false;
    for(int i=0;i<3;i++) { //yoko
      if(str[i][0] == str[i][1] && str[i][1] == str[i][2] && str[i][0] != '+') {
        cout << str[i][0] << endl;
        r = true;
        break;
      }
    }

    if(r) continue;

    for(int i=0;i<3;i++) { //tate
      if(str[0][i] == str[1][i] && str[1][i] == str[2][i] && str[0][i] != '+') {
        cout << str[0][i] << endl;
        r = true;
        break;
      }
    }

    if(r) continue;

    if(str[0][0] == str[1][1] && str[1][1] == str[2][2] && str[0][0] != '+') {  //naname
      cout << str[0][0] << endl;
      continue;
    }

    if(str[0][2] == str[1][1] && str[1][1] == str[2][0] && str[0][2] != '+') {  //naname
      cout << str[0][2] << endl;
      continue;
    }

    cout << "NA" << endl;
    continue;

  }
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 777777753
using namespace std;
typedef long long ll;

int main(){
  int N, K;  cin >> N >> K;
  vector<int> h(N);
  rep(i, 0, N)  cin>>h[i];
  sort(all(h));
  int min = 1000000000;
  rep(i, K-1, N){
    min = (min>h[i]-h[i-K+1]) ? h[i]-h[i-K+1] : min;
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
char a[1001][1001];
#define DADAH ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
    DADAH

  string s;

  cin>>s;

  if(s=="AAA" or s=="BBB")cout<<"No";
  else cout<<"Yes";
    return 0;

}


Measured memory_bytes: 256
s = gets.chomp.split("")

s1, s2 = []

if s.size % 2 == 0 then
	s1 = s[0 ... s.size / 2]
	s2 = s[s.size / 2 .. -1]
else
	s1 = s[0 ... s.size / 2]
	s2 = s[s.size / 2 + 1 .. -1]
end

s2 = s2.reverse

count = 0

s1.each_with_index{ |ss, i|
	if ss != s2[i] then
		count += 1
	end
}

puts count

Measured memory_bytes: 1788
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int H  = keyboard.nextInt();
		int W  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		String m = "";
		char[][] masu = new char[H][W];
		
		
		for(int i=0; i<H; i++) {
			m = keyboard.next();
			for(int j=0; j<W;j++) {
				masu[i][j] = m.charAt(j);
			}
		}
		
		int ans = 0;
		int conH = 1 << H;
		int conW = 1 << W;
		
		for(int Hnuru=0; Hnuru<conH; Hnuru++) {
			for(int Wnuru=0; Wnuru<conW; Wnuru++) {
				int count = 0;
				char[][] masu2 = new char[H][W];
				for(int gyou=0; gyou<H; gyou++) {
					for(int retu=0; retu<W; retu++) {
						if((Hnuru >> gyou) %2 == 1 || (Wnuru >> retu) %2 == 1) {
							masu2[gyou][retu] = '.';
						}
						else {
							masu2[gyou][retu] = masu[gyou][retu];
						}
						if(masu2[gyou][retu] == '#') {
							count++;
						}
						
					}
				}
				if(count == K) {
					ans++;
				}
				
			} 
		}
		
		
		System.out.print(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 37880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  long long ans=K;
  for(int i=1;i<N;i++){
    ans*=K-1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n; cin >> n;
    if (n % 2) {
        cout << 0; return;
    }
    n >>= 1;
    int ans = 0;
    while (n) {
        n /= 5; 
        ans += n;
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int n, m, k, p;
char a[102][102];
int b[102];

int main() {
	for (int i = 0; i < 102; i++)b[i] = 100;
	cin >> n >> m;
	p = 0;

	for (int i = 0; i < n; i++) {
		k = 0;
		cin >> a[p];
		for (int j = 0; j < m; j++) {
			if (a[p][j] == '.')k++;
		}
		if (k == m)p--;
		p++;
	}
	n = p;
	
	p = 0;
	for (int j = 0; j < m; j++) {
		k = 0;
		for (int i = 0; i < n; i++) {
			if (a[i][j] == '.')k++;
		}
		if (k == n) {
			b[p] = j;
			p++;
		}
	}
	for (int i = 0; i < n; i++) {
		p = 0;
		for (int j = 0; j < m; j++) {
			if (b[p] != j) {
				cout << a[i][j];
			}
			else {
				p++;
			}
		}
		cout << '\n';
	}
	cin >> n;
	return 0;

}


Measured memory_bytes: 256