akhauriyash/Code-Regression huggingface dataset:
s = input()
n = len(s)

def dfs(i, f, sum_):
    if i == n-1:
        if sum_ == 7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1, f+'+'+s[i+1], sum_+int(s[i+1]))
        dfs(i+1, f+'-'+s[i+1], sum_-int(s[i+1]))
        
print(dfs(0, s[0], int(s[0])))

Measured memory_bytes: 3064
N, A, B, C = gets.split.map(&:to_i)
L = N.times.map{gets.to_i}

def dfs(i, a, b, c)
    if i == N
        # if a == A || b == B || c == C
        #     Float::INFINITY
        # else  
        #aもbもcも数が減っていない == 
        if a == A || b == B || c == C
            Float::INFINITY
        else  
            # return [a.abs,b.abs,c.abs]
            #一本だけの場合には+10ではないので、a,b,cでそれぞれ-30する
            return a.abs + b.abs + c.abs - 30
        end
    else

        return [dfs(i + 1, a, b, c), #使わない
                dfs(i + 1, a - L[i], b, c) + 10, #Aに使う
                dfs(i + 1, a, b - L[i], c) + 10, #Bに使う
                dfs(i + 1, a, b, c - L[i]) + 10 #Cに使う
        ].min
    end 
end
p dfs(0, A, B, C)


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  cout << n * n * n << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input().rstrip())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
    
    #https://note.nkmk.me/python-union-find/
    
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n
    
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]
    
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
    
            if x == y:
                return
    
            if self.parents[x] > self.parents[y]:
                x, y = y, x
    
            self.parents[x] += self.parents[y]
            self.parents[y] = x
    
        def size(self, x):
            return -self.parents[self.find(x)]
    
        def same(self, x, y):
            return self.find(x) == self.find(y)
    
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
    
        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]
    
        def group_count(self):
            return len(self.roots())
    
        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}
    
        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
    h,w=MI()
    uf=UnionFind(h*w)
    lis=[[0]*w for i in range(h)]
    for i in range(h):
        s=SI()
        for j in range(w):
            if s[j]=="#":
                lis[i][j]=1
    step=[[0,1],[0,-1],[-1,0],[1,0]]
    for i in range(h):
        for j in range(w):
            for x,y in step:
                if not (0<=i+x<h and 0<=j+y<w):
                    continue
                if lis[i][j]!=lis[i+x][j+y]:
                    uf.union(w*i+j,w*(i+x)+(j+y))
    ans=0
    dic=defaultdict(lambda:[0,0])
    for i in range(h):
        for j in range(w):
            dic[uf.find(w*i+j)][lis[i][j]==1]+=1
    for p in dic.keys():
        ans+=dic[p][0]*dic[p][1]
    print(ans)
if __name__=="__main__":
    main()
            
            
                
                
    
        
    
            
            



Measured memory_bytes: 91840
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

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

long long ngcd(vector<long long> a) {
  long long res = a[0];
  for(int i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}

long long nlcm(vector<long long> a){
  long long res = a[0];
  for(int i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  cout<<nlcm(a)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, X);
  print(X < 1200 ? "ABC" : "ARC");
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
typedef pair<int,int> P;
int ans;
int w,h;
string map[50];
int dx[4] = {1,0,-1,0}, dy[4] = {0,-1,0,1};
int dfs(P s);

int main(){
  int i,j;
  P s;
  //cout <<x<<y<<endl;
  while(1){
    cin >> w >> h;
    cin.ignore();
    if(w == 0 && h == 0) break;
    for(i = 0;i < h;i++) getline(cin,map[i]);
    while(map[s.second][s.first] != '@'){
      //cout << map[y][x]<<endl;
      s.first++;
      if(s.first > w-1){
	s.second++;
	s.first = 0;
      }
    }
    dfs(s);
    cout << ans<<endl;
    s.first = s.second = ans = 0;
  }
  return 0;
}

int dfs(P s){
  int i;
  P tmp;
  map[s.second][s.first] = '#';
  ans++;
  //cout <<"x = " << s.first << " y = " << s.second << endl;
  for(i = 0; i<4;i++){
    if(s.first + dx[i] > -1 && s.first + dx[i] < w && s.second + dy[i] < h && s.second + dy[i] > -1 && map[s.second + dy[i]][s.first + dx[i]] == '.'){
      tmp.first = s.first + dx[i];
      tmp.second = s.second + dy[i];
      dfs(tmp);
    }
  }
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int dp[214514];
signed main() {
	int n; vector<int>money;
	cin >> n;
	int six = 1, nine = 1;
	while (six <= n) {
		money.push_back(six); money.push_back(nine);
		six *= 6, nine *= 9;
	}
	fill(dp, dp + n + 1, inf);
	dp[0] = 0;
	rep(i, n) {
		rep(j, money.size()) {
			if (i + money[j] > n)continue;
			dp[i + money[j]] = min(dp[i + money[j]], dp[i] + 1);
		}
	}
	cout << dp[n] << endl;
}


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

int main() {
  int n;
  cin>>n;
  ll a[100010];
  ll b[100010];
  for (int i=0; i<n; i++)
    scanf("%lld %lld",a+i,b+i);

  ll ans=0;
  for (int i=n-1; i>=0; i--) {
    a[i]+=ans;
    ans+=((a[i]+b[i]-1)/b[i])*b[i]-a[i];
  }

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

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(100000)
N = int(input())
svt = []

def dfs(num):
    if num>1000000000:
        return
    #elif num<100:
    #    return
    else:
        svt.append(int(str(num)+'3'))
        dfs(int(str(num)+'3'))
        svt.append(int(str(num)+'5'))
        dfs(int(str(num)+'5'))
        svt.append(int(str(num)+'7'))
        dfs(int(str(num)+'7'))

def check753(num):
    exist3 = False
    exist5 = False
    exist7 = False
    s = str(num)
    for c in s:
        if c=='3':
            exist3 = True
        elif c=='5':
            exist5 = True
        elif c=='7':
            exist7 = True
    if exist3 and exist5 and exist7:
        return True
    else:
        return False


dfs(0)
svt = sorted(svt)
svt = svt[12:]
#print(svt)
count = 0
for i in range(len(svt)):
    if svt[i]>N:
        break
    if check753(svt[i]):
        count += 1
print(count)



Measured memory_bytes: 7348
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 10005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(c<=b) puts("delicious");
    else if(c <= a+b) puts("safe");
    else
        puts("dangerous");
    return 0;
}


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

int main() {
  ll N;
  cin >> N;
  vector<char> color(N);
  ll count=0;
  for(ll i=0;i<N;i++){
    cin >> color.at(i);
    if(color.at(i)=='R'){
      count++;
    }
  }
  ll count2=0;
  for(ll j=0;j<count;j++){
    if(color.at(j)=='W'){
      count2++;
    }
  }
  cout << count2 <<endl;
}

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


void solve(long long X){
  bool solved = false;
  for (int a=-1000; a<1000; a++) {
    if (solved) return;
    for (int b=-1000; b<1000; b++) {
      if (pow(a, 5) - pow(b, 5) == X) {
        cout << a << " " << b << endl;
        solved = true;
        return;
      }
    }
  }
}

long long calc(long long a, long long b) {
  return pow(a, 5) - pow(b, 5);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1ll<<60;

vvec<int> node(100100, vec<int>());
vec<int> dp(100100, -1);

int dfs(int v) {
    if (dp[v] != -1) return dp[v];
    int res = 0;
    for (int nv : node[v]) {
        //cout << v << ":" << nv << "here" << endl;
        res = max(res, dfs(nv) + 1);
    }
    return dp[v] = res;
    //return res;
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        node[x].push_back(y);
    }
    int ans = 0;
    rep(i, n) ans = max(ans, dfs(i));
    cout << ans << endl;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3600
#include<iostream>
 
using namespace std;
 
int main()
{
  int x,y;
  cin>>x>>y;
  for(int i=0;i<=100;i++)
  {
    int a=x-i;
    if(a>=0){
      if(i*2 + a*4==y){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll calc(ll X){
    ll ret=0;
    ll st=X/4*4;
    for(ll x=st;x<=X;x++) ret^=x;
    return ret;
}

int main() {
    ll a,b;
    cin>>a>>b;
    ll ans=calc(a-1)^calc(b);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
    int N;
    std::cin >> N;

    char* str = new char[3];

    int i = 0;
    while (N > 0) {
        int v = N % 10;
        if (v == 1) {
            str[2 - i]='9';
        } else {
            str[2 - i]='1';
        }
        N /= 10;
        i++;
    }
    printf("%s\n", str);

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        long answer = 0;
        for (int i = A; i <= B; i++) {
            String s = Integer.toString(i);
            char[] d = s.toCharArray();
            if (kaibun(d)) {
                answer += 1;
            }
        }
        System.out.println(answer);
    }
    public boolean kaibun(char[] d) {
        int length = d.length;
        for (int i = 0; i < length / 2; i++) {
            if (d[i] != d[length-i-1]) {
                return false;
            }
        }
        return true;
    }
}


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

int main() {
  int N;
  string S;
  cin>>N;
  
  for (int i=0;i<N;i++){
    cin>>S;
    
    if (S!="Y" && i==N-1){
      cout<<"Three"<<endl;
    }
    
    else if (S!="Y"){
      continue;
    }
    
    else{
      cout<<"Four"<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  double N, K; cin >> N >> K;
  vector<double> prob(18);
  prob[0] = 1;
  for(int i=1; i<18; i++){
    prob[i] = prob[i-1]/2;
  }
  double ans;
  int cnt, tmp, loop;
  if (N<K-1){
    loop = N;
  }else {
    loop = K-1;
  }
  ans = max(0, (int)N-(int)K+1);
  
  for (int i=1; i<=loop; i++){
    cnt = 0;
    tmp = i;
    while (tmp<K){
      cnt++;
      tmp *= 2;
    }
    ans += prob[cnt];
  }
  
  cout << fixed << setprecision(10) << ans/N << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-25 14:22:53 +0900
# LastModified: 2020-06-25 14:40:12 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    a = [0]
    for i in range(n):
        a.append(int(input()))
    cnt = 0
    flag = [0]*(n+1)
    current = 1
    tmp=0
    while flag[current] == 0:
        flag[current] = flag[tmp] + 1
        tmp = current
        current = a[current]
        if current == 2:
            print(flag[tmp])
            return
    print("-1")


if __name__ == "__main__":
    main()


Measured memory_bytes: 16616
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define MOD 1000000007
#define MAX 5000005
#define endl "\n"
string in;
lli n;
lli md[55][55];
string out;
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
bool condition(lli i, lli j){
    if(abs(i-j) == 0)
        return true;
    if(out[i] == 'Y' && in[j] == 'Y'){
        if(abs(i-j)<2)
            if(i > -1 && i < n && j > -1 && j < n)
                return true;
    }
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
 /*   freopen("biginput.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    lli t;
    t = 1;
    lli pa = 0;
    while(t--){
       pa++;
       cin>>n;
       if(n < 600){
           cout<<8<<endl;
       }
       else if(n < 800){
           cout<<7<<endl;
       }
       else if(n < 1000){
           cout<<6<<endl;
       }
       else if(n < 1200){
           cout<<5<<endl;
       }
       else if(n < 1400){
           cout<<4<<endl;
       }
       else if(n < 1600){
           cout<<3<<endl;
       }
       else if(n < 1800){
           cout<<2<<endl;
       }
       else if(n < 2000){
           cout<<1<<endl;
       }
       
    }
}

Measured memory_bytes: 3640
def resolve():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    ch -= 1
    cw -= 1
    dh, dw = map(int, input().split())
    dh -= 1
    dw -= 1
    maze = []
    for _ in range(h):
        maze.append(list(input()))

    final = [[10**9] * w for _ in range(h)]
    from collections import deque
    nxt = [[ch, cw]]
    nxt = deque(nxt)
    final[ch][cw] = 0

    while nxt:
        nowh, noww = nxt.popleft()
        for i, j in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
            if 0 <= nowh + i < h and 0 <= noww + j < w and maze[nowh + i][noww + j] == ".":
                if final[nowh + i][noww + j] > final[nowh][noww]:
                    final[nowh + i][noww + j] = final[nowh][noww]
                    nxt.appendleft([nowh + i, noww + j])


        for i in range(max(0, nowh - 2), min(h, nowh + 3)):
            for j in range(max(0, noww - 2), min(w, noww + 3)):
                if maze[i][j] == ".":
                    if final[i][j] > final[nowh][noww] + 1:
                        final[i][j] = final[nowh][noww] + 1
                        nxt.append([i, j])
    if final[dh][dw] == 10**9:
        print(-1)
    else:
        print(final[dh][dw])

resolve()

Measured memory_bytes: 139948
n=int(input())
line=input().split(" ")
colors=[0,0,0,0]
s=0
for i in range(n):
	if line[i]=="G":
		colors[0]=1
	if line[i]=="W":
		colors[1]=1
	if line[i]=="P":
		colors[2]=1
	if line[i]=="Y":
		colors[3]=1
s=sum(colors)
if s==3:
	print ("Three")
else:
	print("Four")

Measured memory_bytes: 3064
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n=r()
a=rl()
money=1000
s=0

for i in range(n):
    if i==n-1:
        money+=s*a[i]
    else:
        if a[i]<=a[i+1]:
            money+=s*a[i]
            s=money//a[i]
            money%=a[i]
        else:
            money+=s*a[i]
            s=0
print(money)

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

using namespace std;
using ll = long long;

const int N = 3000 + 1;

int k, n, a[ 101 ], DP[ 100005 ][ 2 ];

int dfs(int stonesLeft = k, int turn = 0) {
    if( stonesLeft < a[ 1 ] ) return turn;
    int &ret = DP[ stonesLeft ][ turn ];
    if( ~ret ) return ret;
    if( turn == 0 ) {
        ret = 0;
        for(int i = 1; i <= n; i += 1) {
            if( a[ i ] > stonesLeft )
                break;
            ret |= dfs(stonesLeft - a[ i ], 1 );
        }
    } else {
        ret = 1;
        for(int i = 1; i <= n; i += 1) {
            if( a[ i ] > stonesLeft )
                break;
            ret &= dfs(stonesLeft - a[ i ], 0 );
        }
    }
    return ret;
}

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

    cin >> n >> k;
    for(int i = 1; i <= n; i += 1)
        cin >> a[ i ];
    sort(a + 1, a + n + 1);
    memset(DP, -1, sizeof DP);
    cout << ( dfs() == 1 ? "First" : "Second" ) << '\n';
    return 0;
}


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


int main(){
    ll N; cin >> N;
    vector<char> c(N);
    vector<ll> SR(N);
    ll sum = 0;
    rep(i,N){
        cin >> c[i];
        if(c[i] == 'R') sum++;
        SR[i] = sum;
    }
    if(sum == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << sum - SR[sum-1] << endl;
}

Measured memory_bytes: 5100
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <cmath>
#include <queue>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 200010;

int A[N];

struct SegmentTree{
	
	int Min[N << 2];

	#define lc (o << 1)
	#define rc (o << 1 | 1)
	#define M ((L + R) >> 1)

	void build(int o, int L, int R){
		if(L == R) Min[o] = A[L];
		else{
			build(lc, L, M), build(rc, M + 1, R);
			Min[o] = min(Min[lc], Min[rc]);
		}
	}

	int query(int o, int L, int R, int l, int r){
		//if(o == 1) printf(":(%d %d)\n", l, r);
		if(l <= L && R <= r) return Min[o];
		else{
			int ret = 1e9;
			if(l <= M) ret = min(ret, query(lc, L, M, l, r));
			if(M < r) ret = min(ret, query(rc, M + 1, R, l, r));
			return ret;
		}
	}
}T[2];

set<int> S;
priority_queue<int, vector<int>, greater<int> > q;

typedef set<int>::iterator it;

int n, P[N], pos[N];

void update(int L, int R){
	if(L >= R - 1) return;
	int t;
	q.push(t = T[L & 1].query(1, 1, n / 2, L / 2 + 1, (R - 1) / 2));
	//printf("[%d, %d]: %d\n", L, R, t);
}

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &P[i]), pos[P[i]] = i;
	For(i, 1, n / 2) A[i] = P[i * 2 - 1];
	T[0].build(1, 1, n / 2);
	For(i, 1, n / 2) A[i] = P[i * 2];
	T[1].build(1, 1, n / 2);
	S.insert(0), S.insert(n + 1);
	q.push(T[0].query(1, 1, n / 2, 1, n / 2));
	For(i, 1, n / 2){
		int s = q.top(); q.pop();
		int r = *S.lower_bound(pos[s]);
		//printf("%d %d\n", pos[s], r);
		int t = T[pos[s] & 1].query(1, 1, n / 2, pos[s] / 2 + 1, r / 2);
		S.insert(pos[s]), S.insert(pos[t]);
		//printf("%d %d", pos[s], pos[t]);
		it p = S.find(pos[s]);
		if(p != S.begin()){
			it x = p; --x;
			update(*x, pos[s]);
		}
		update(pos[s], pos[t]);
		++p, ++p;
		if(p != S.end()) update(pos[t], *p);
		//printf("ans = %d %d\n", s, t, i == n ? '\n' : ' ');
		printf("%d %d%c", s, t, i == n / 2 ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 19200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll ans = 1;
    ll N;
    cin >> N;
    vector<ll>H(N);
    for(ll i = 0; i < N; i++)cin >> H[i];
    for(ll i = N - 2; i >= 0; i--){
        if(H[i] - 1 > H[i + 1])ans = 0;
        else if(H[i] - 1 == H[i + 1])H[i]--;
    }

    Say(ans);

    return 0;
}

Measured memory_bytes: 1024
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;

struct State {
  string board;
  int pos;
}

void solve(ref int[string] hash) {
  auto directions = [1, -1, 4, -4];
  State[] queue;
  string init = "01234567";
  hash[init] = 0;
  queue ~= State(init, 0);
  while (!queue.empty) {
    State state = queue.front;
    queue.popFront;
    foreach(int i, int d; directions) {
      int npos = state.pos + d;
      if (npos < init.length && npos >= 0 &&
          !(state.pos == 3 && i == 0) && !(state.pos == 4 && i == 1)) {
        char[] new_board = state.board.dup;
        swap(new_board[state.pos], new_board[npos]);
        string str = to!string(new_board);
        if (hash.get(str, -1) == -1) {
          State s;
          s.board = str;
          s.pos = npos;
          hash[s.board] = hash[state.board] + 1;
          queue ~= s;
        }
      }
    }
  }
}

void dump(int[string] hash) {
  foreach(string key, int value; hash) {
    writeln(key, " => ", value);
  }
}

void main() {
  string line;
  int[string] hash;
  solve(hash);
  while ((line = readln()).length != 0) {
    writeln(hash[line.strip.chomp.removechars(" ")]);
  }
}

Measured memory_bytes: 4136
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
from itertools import permutations

n,m,r = map(int,input().split())
rr = np.array(list(map(int,input().split()))) - 1

L = np.zeros((n,n),int)
for _ in range(m):
    a,b,c = map(int,input().split())
    L[a-1,b-1] = c

shortest = floyd_warshall(L, directed = False)

ans = float('inf')

for route in permutations(rr,len(rr)):
    ans = min(ans, shortest[route[:-1],route[1:]].sum())
print(int(ans))

Measured memory_bytes: 18324
def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    max_height = 0

    for height in A:
        if max_height < height:
            max_height = height
        else:
            count += max_height - height
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32100
#include <iostream>

int main(){
    
    int a, b;
    std::cin>>a>>b;
    
    if(a<b)std::cout << "a < b" << std::endl;
    if(a==b)std::cout << "a == b" << std::endl;
    if(a>b)std::cout << "a > b" << std::endl;
    
    return 0;
}

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



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

Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
using static Utils;
class Program
{


    void Solve()
    {
        var N = io.Int;
        var K = io.Int;
        var h = new int[N];
        for (var i = 0; i < N; i++) {
            h[i] = io.Int;
        }
        WriteLine(h.Count(x => x >= K));
    }


    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();
    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }

}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}
class Utils
{
    public static T id<T>(T x) => x;
}

Measured memory_bytes: 16096
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.length(); i++) {
        char ne = (s[i] - 'A' + n) % 26 + 'A';
        cout << ne;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0;
    for (auto aa : irange(0, a + 1)) {
        for (auto bb : irange(0, b + 1)) {
            for (auto cc : irange(0, c + 1)) {
                ans += ((500 * aa + 100 * bb + 50 * cc) == x);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    char S[101];
    long K;
    scanf("%s%ld", S, &K);

    for (int i = 0; ; i++) {
        if (S[i] != '1' || i == K - 1) {
            printf("%c\n", S[i]);
            return 0;
        }
    }
}


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

using namespace std;

int main()
{
	int n, s;
	vector<int> flags;

	while ( cin >> n >> s )
	{
		if ( n == 0 && s == 0 )
		{
			break;
		}

		flags.clear();
		for ( int i = 0; i < 10; i++ )
		{
			flags.push_back( i < n ? 1 : 0 );
		}
		sort( flags.begin(), flags.end() );

		int count = 0;

		do
		{
			int sum = 0;

			for ( unsigned int i = 0; i < flags.size(); i++ )
			{
				if ( flags[i] )
				{
					sum += i;
				}
			}

			if ( s == sum )
			{
				count++;
			}
		} while ( next_permutation( flags.begin(), flags.end() ) );

		cout << count << endl;
	}
	
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
const int PrimeMax = 50001;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}
int ans[50001];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  vary(int,v,0,0);
  v.clear();
  rep(i,PrimeMax){
    if(is_prime[i] != 0){
      v.pb(i);
    }
  }
  REP(i,1,v.size()){
    REP(j,i,v.size()){
      if(v[i] + v[j] < PrimeMax){
        ans[v[i]+v[j]]++;
      }
    }
  }
  int n;
  while(cin >> n&&n){
    cout << ans[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 3532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nab = ReadInts();
            int ans = 0;
            for (int i = 1; i <= nab[0]; i++)
            {
                if(goukei(i)>=nab[1] & goukei(i) <= nab[2])
                {
                    ans += i;
                }
            }
            WriteLine(ans);
        }
        static int goukei(int n )
        {
            var str = n.ToString();
            var result = 0;
            for (int i = 0; i < str.Length; i++)
            {
                result += int.Parse(str[i].ToString());
            }
            return result;
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll nxt[111111][33];

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

	string s, t;cin >> s >> t;
	vector<ll> tmp(33, LLINF);
	REP(seica, 2)REV(i, s.size()){
		REP(j, 33){
			nxt[i][j] = tmp[j];
		}
		tmp[s[i]-'a'] = i;
	}

	ll ans = tmp[t[0]-'a'];
	ll now = ans;
	if(ans == LLINF){
		cout << -1 << endl;
		return 0;
	}
	REP(i, t.size() - 1){
		ll tsugi = nxt[now][t[i+1]-'a'];
		if(tsugi == LLINF){
			cout << -1 << endl;
			return 0;
		}
		ans += (tsugi - now) + (tsugi <= now) * (ll)s.size();
		now = tsugi;
	}

	cout << ans + 1 << endl;

	return 0;
}


Measured memory_bytes: 27216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end());
	vector<ll> b(n + 1);
	for(int i = 0; i < n; ++i){ b[i + 1] = b[i] + a[i]; }
	int li = 0, ri = n;
	while(li < ri){
		const int ci = li + (ri - li) / 2;
		int cur = ci + 1;
		while(cur < n){
			int lj = 0, rj = n;
			while(lj < rj){
				const int cj = lj + (rj - lj) / 2;
				if(a[cj] <= 2 * b[cur]){
					lj = cj + 1;
				}else{
					rj = cj;
				}
			}
			if(cur == lj){ break; }
			cur = lj;
		}
		if(cur < n){
			li = ci + 1;
		}else{
			ri = ci;
		}
	}
	cout << (n - li) << endl;
	return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var p = (int)1e9 + 7;
            var answer = 1L;
            for (var i = 1; i <= N; i++)
            {
                answer *= i;
                answer %= p;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int K = Integer.parseInt(tokens[1]);

		in.close();
		int count = 0;

		for (int i = 1; i <= N; i = i + 2) {
			++count;
		}
		if (count >= K) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;

  int water = 0,suger = 0;
  double con = 0;

  for(int i = 0;100*A*i <= F;i++) {
    for(int j = 0;100*B*j <= F;j++) {
      int w = 100*(A*i+B*j);
      if(w > F) break;
      for(int k = 0;k*C <= F;k++) {
        for(int l = 0;l*D <= F;l++) {
          int s = k*C+l*D;
          if(w/100*E < s || s+w > F) break;
          if(s+w == 0) continue;
          double c = 100*s/ (double)(s+w);
          if(c >= con) {
            con = c;
            suger = s;
            water = w;
          }
        }
      }
    }
  }

  cout << suger + water << " " << suger << endl;
  
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(1000000)

"""解説
いもす法っぽいことする
[入力例]
4 3
1 2
2 3
2 4
2 10
1 100
3 1

[出力例]
"""
def solve():
    N, Q = map(int, sys.stdin.readline().split())
    to = [[] for _ in range(N)]  # 木

    for _ in range(N-1):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1  # 0始まりになるように
        to[a].append(b)  # 無向グラフになるように両方に加える
        to[b].append(a)  # 無向グラフになるように両方に加える

    #print(to)

    ans = [0 for _ in range(N)]
    for _ in range(Q):
        p, x = map(int, sys.stdin.readline().split())
        p = p-1  # 0始まりになるように
        ans[p] += x

    #print(ans)

    def dfs(v, p=-1):
        for u in to[v]:
            if u==p: continue
            ans[u] += ans[v]  # いもす法っぽい累積和をする
            dfs(u, v)

    dfs(0)

    print(*ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 268424
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int main()
{
	//File("");
	int x = 0;
	cin >> x;
	LL a = 0, b = 0;
	a = x / 500, b = x % 500;
	LL ans = a * 1000;
	ans += (b / 5) * 5;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L.sort()
 
from bisect import bisect_left 
cnt = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    t = L[i]+L[j]
    idx = bisect_left(L,t,lo=j+1)
    cnt += max(0,idx-j-1)
print(cnt)

Measured memory_bytes: 44124
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

ll as[100001];

int main(void) {
  ll N;
  cin >> N;
  ll mc = 0;
  for(ll i = 0; i < N; i++)
  {
    ll t; cin >> t;
    mc += t < 0 ? 1 : 0;
    t = t < 0 ? -t : t;
    as[i] = t;
  }

  ll mina = as[0];
  ll mini = 0;
  for(ll i = 0; i < N; i++)
  {
    if (mina > as[i]) {
      mini = i;
      mina = as[i];
    }
  }
  
  ll sum = 0;
  
  for(ll i = 0; i < N; i++)
  {
    sum += as[i];
  }

  if (mc % 2 == 1)
    sum -= mina * 2;

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1024
import math as math
a,b,angle = map(float,input().split())
h = b * math.sin(angle*math.pi/180)
s = a * h / 2
if a < b:
    kata = -a + b * math.cos(angle*math.pi/180)
else:
    kata = a - b * math.cos(angle*math.pi/180)
phi=math.atan(h/kata)
nokori = kata/math.cos(phi)
L = a+b+nokori
print(s)
print(L)
print(h)


Measured memory_bytes: 5716
N,M = list(map(int, input().split()))
A = []
for _ in range(M):
    A.append(list(map(int, input().split())))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


uf = UnionFind(N)
for i in range(M):
    uf.union(A[i][0]-1,A[i][1]-1)

ans = 0
for j in range(N):
    ans = max(ans,uf.size(j))

print(ans)

Measured memory_bytes: 107256
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();

    double ans = 0;

    for (int i=0; i<N; i++) {
      String val = sc.next();
      if (sc.next().equals("JPY")) {
        ans += Integer.parseInt(val);
      } else {
        ans += 380000.0 * Double.parseDouble(val);
      }
    }

    System.out.println(ans);

  }

}

Measured memory_bytes: 23252
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[]
for i in range(N):
    A.append(list(map(int,input().split())))

for i in range(N):
    for j in range(M):
        A[i][j] *= B[j]

ans=0
for i in range(N):
    if sum(A[i])>-C:
        ans+=1
print(ans)

Measured memory_bytes: 3064