akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  string s; cin >> s;
  int n = s.size();
  for(int i = n-1; i>=0; i--) {
    if (i%2 != 0) continue;
    auto tmp = i/2;
    bool flag = true;
    rep(j, tmp) {
      if (s.at(j) != s.at(j+tmp)) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  long long int n;
  cin >> n;
  long long int i, a = n, c;
  for(i=1;i<=sqrt(n)+1;i++){
    if(n%i!=0){
      continue;
    }
    c = i+n/i-2;
    if(c<a){
      a = c;
    }
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int t,n,a;
int main()
{
	cin>>t>>n;
	for(int i=1;i<=n;i++)
	{
	    cin>>a;
	    t-=a;
	}
	if(t<0) cout<<-1;
	else cout<<t;
}

Measured memory_bytes: 3636
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input! {
        n: usize,
        xyss: [[(usize1, usize)]; n],
    }

    let mut ans = 0;

    for b in 0_usize..(1 << n) {
        let f = |i: usize| b & (1 << i) != 0;

        let mut ok = true;

        for (i, xys) in xyss.iter().enumerate() {
            for &(x, y) in xys.iter() {
                if f(i) {
                    if y == 1 && !f(x) {
                        ok = false;
                    }
                    if y == 0 && f(x) {
                        ok = false;
                    }
                }
            }
        }

        if ok {
            ans = max(ans, b.count_ones());
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4476
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
a=0
b=0
cnt=0
from  itertools import permutations
for i in permutations(range(1,1+n)):
    cnt+=1
    i=list(i)
    if     i==p:
        a=cnt
        break
cnt=0
for i in permutations(range(1,1+n)):
    cnt+=1
    i=list(i)
    if     i == q:
        b=cnt
        break


print(abs(a-b))

Measured memory_bytes: 40300
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll k, q;
    cin >> k >> q;
    ll d[5003];
    for(int i = 0; i < k; i++) cin >> d[i];
    for(int c = 0; c < q; c++){
        ll n, x, m;
        cin >> n >> x >> m;
        x %= m;
        ll f[5003];
        f[0] = 0;
        ll eq = 0;
        for(int i = 1; i <= k; i++){
            f[i] = f[i - 1] + d[i - 1] % m;
            if(d[i - 1] % m == 0){
                eq += (n - 1) / k;
                if(i <= (n - 1) % k) eq++;
            }
        }
        ll r = x + f[k] * ((n - 1) / k) + f[(n - 1) % k];
        cout << n - 1 - eq - r / m << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  vector<vector<int> > adj(n);
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[--u].push_back(--v);
    adj[v].push_back(u);
  }
  vector<int> dis(n);
  auto bfs = [&] (int start) {
    for (int i = 0; i < n; i++) {
      dis[i] = INT_MAX;
    }
    dis[start] = 0;
    queue<int> que;
    que.push(start);
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int v : adj[u]) {
        if (dis[v] > dis[u] + 1) {
          dis[v] = dis[u] + 1;
          que.push(v);
        }
      }
    }
    return max_element(dis.begin(), dis.end()) - dis.begin();
  };
  cout << (dis[bfs(bfs(0))] % 3 != 1 ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 13556
#include <iostream>
    #include <algorithm>
    using namespace std;
    int main()
    {
      int n, m;
      cin >> n >> m;
      int tmp = min(m, n);
      if (tmp == m)
      {
        for (int i = 0; i < n; i++)
            cout << m;
      }
      else
      {
          for (int i = 0; i < m; i++)
            cout << n;
      }
      return 0;
    }

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

int main(){
   char search[21], word[21];
   int count=0;
   int i;
   
   scanf("%s", search);
   while(1){
       scanf(" %s", word);
       if(strcmp(word, "END_OF_TEXT")==0)break;
       for(i=0;word[i]!='\0';i++){
           word[i]=tolower(word[i]);
       }
       if(strcmp(word, search)==0){
           count++;
       }
   }
   printf("%d\n", count);

   return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



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



int main(){
    int n,k;cin>>n>>k;
    int a[n];for(int i=0;i<=n-1;i++)cin>>a[i];
    sort(a,a+n);
    int l=0,r=n;
    while(l<r){
        int m=(l+r)/2;
        bool c[k];memset(c,false,sizeof(c));c[0]=true;
        for(int i=0;i<=n-1;i++){
            if(i!=m){
                for(int j=k-1;j>=a[i];j--){
                    c[j]|=c[j-a[i]];
                }
            }
        }
        bool flag=false;
        int last=max(0,k-a[m]);
        for(int j=k-1;j>=last;j--)flag|=c[j];
        if(flag)r=m;
        else l=m+1;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

memo = [-1]*500

def fibo(x):
    if memo[x] != -1:
        return memo[x]
    
    if x == 0 or x == 1:
        ans=1
        memo[x] = ans
        return ans
    
    ans = fibo(x-1) + fibo(x-2)
    memo[x] = ans
    return ans

print(fibo(N))


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
  while(1){
    int n,m; cin >> n >> m; 
    if(n == 0 && m == 0) break;
    vector<vector<int> > friend_list(n+1);
    for(int i=0; i<m; i++){
      int a,b; cin >> a >> b;
      friend_list[a].push_back(b);
      friend_list[b].push_back(a);
    }
    set<int> fri;
    for(int i=0; i<friend_list[1].size(); i++){
      fri.insert( friend_list[1][i] );
    }
    set<int> frifri;
    for(auto f : fri){
      for(int i=0; i<friend_list[f].size(); i++)
	frifri.insert( friend_list[f][i] );
    }
    for(auto f : fri){
      frifri.insert(f);
    }    
    if(frifri.find(1) != frifri.end()) frifri.erase(1);
    cout << frifri.size() << "\n";

    
  }
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
ll n,m;
int mn=1e8,mx=0;
int l[100100],r[100100];
int main() {
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>l[i]>>r[i];
        mn=min(mn,r[i]);
        mx=max(mx,l[i]);

    }
    ll k=mn-mx+1;
    k=max(k,0LL);
    cout<<k;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a<=c && d<=b){
    cout<<d-c<<endl;
  }
  else if(a<=c && c<=b && b<=d){
    cout<<b-c<<endl;
  }
  else if(c<=a && a<=d && d<=b){
    cout<<d-a<<endl;
  }
  else if(c<=a && b<=d){
    cout<<b-a<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}


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

typedef long long ll;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int K,cnt=0;
    char ans;
    string S;
    cin>>S>>K;

    for(int i=0;i<S.size();++i){
        if(S[i] == '1') ++cnt;
        if(S[i] != '1'){ans = S[i];break;}
    }

    if(cnt>=K) ans = '1';

    put(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

int n,q;
int a[4000005],com[4000005],c[4000005],d[4000005];
int N=2147483648-1;
int sa;

void update(int x,int y){
  x+=sa;
  a[x]=y;
  while(x>0){
    x=(x-1)/2;
    a[x]=min(a[x*2+1],a[x*2+2]);
  }
}

int find(int x, int z, int k, int l, int r){
  if(x<=l && r<=z) {
    return a[k];
  }
  if(r<=x || z<=l) return N;
  else {
    int vl=find(x,z,k*2+1,l,(l+r)/2);
    int vr=find(x,z,k*2+2,(l+r)/2,r);
    //printf("%d %d %d\n",k,vl,vr);
    return min(vl,vr);
  }
}

int pow(int x){
  int i=1;
  while(true){
    if(i<=x && x <(i*2)) return (i*2);
    else i*=2;
  }
}

int main(){


  scanf("%d%d",&n,&q);

  for(int i=0; i<q; i++){
    scanf("%d%d%d", &com[i],&c[i],&d[i]);
  }

  sa=pow(n)-1;
  int ni=4*sa;

  for(int i=0;i<ni;i++){
    a[i]=N;
  }

  for(int i=0;i<q;i++){
    if(com[i]==0){
      update(c[i],d[i]);
    }else{
      printf("%d\n",(find(c[i],d[i]+1,0,0,sa+1)));

    }
  }


  return 0;
}

Measured memory_bytes: 9620
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

typedef pair<ll, ll> P;
vec d;
struct edge {
    ll to, cost;
};
vector<vector<edge>> G;

void dijkstra (ll s, ll V) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(V, inf);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

ll dfs(ll v) {
    if (d[v] != -inf) return d[v];
    ll ret = -1;
    vec ord;
    for (auto nv : G[v]) {
        ord.push_back(dfs(nv.to));
    }
    sort(ord.begin(), ord.end());
    ll n = ord.size();
    Rep (i, n) {
        chmax(ret, ord[i]+n-1-i);
    }
    d[v] = ret + 1;
    return d[v];
}

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

    ll N;
    cin >> N;
    G.assign(N, vector<edge>());
    d.assign(N, -inf);
    for (ll i = 1; i < N; i++) {
        ll a;
        cin >> a;
        a--;
        G[a].push_back({i, 1});
    }

    dfs(0);

    // Rep (i, N) {
    //     cout << d[i] << " \n"[i==N-1];
    // }

    cout << dfs(0) << "\n";
    return 0;
}

Measured memory_bytes: 17408
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s = s.trim_right().to_owned();
    let vec: Vec<&str> = s.split_whitespace().collect();
    let a: i32 = vec[0].parse().unwrap_or(0);
    let b: i32 = vec[1].parse().unwrap_or(0);
    println!("{}", format!("{}", (a * b) - ( a + b - 1 )));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 5; i++) {
            if (nextInt(scanner) == 0) {
                System.out.println(i + 1);
            }
        }
    }

    private static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }

    private static long nextLong(Scanner scanner) {
        return Long.parseLong(scanner.next());
    }

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}





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

using namespace std;
const int maxn = 4;
char a[maxn], b[maxn];
int main()
{
    cin >> a >> b;
    int ok = 1;
    for (int i = 0; i < 3; i++)
        if (a[i] != b[2 - i])
            ok = 0;
    if (ok)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())


def f(x):
    if x < 0:
        return -1
    elif x > 0:
        return 1
    else:
        return 0


if f(a) == 0 or f(b) == 0:
    ans = "Zero"
elif f(a) == -1 and f(b) == -1:
    diff = b - a
    if (diff + 1) % 2 == 0:
        ans = "Positive"
    else:
        ans = "Negative"
elif f(a) == 1 and f(b) == 1:
    ans = "Positive"
else:
    ans = "Zero"

print(ans)


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, k;
  cin >> n >> k;

  if (n%k == 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = n % k;
  ans = min(ans, abs(k-ans));
  cout << ans << endl;

  return 0;
}

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

signed main(){
    int N,K;
    cin >> N >> K;
    
    if(K == 1){
        cout << 0 << endl;
        return 0;
    }else if(N<K){
        if(N<=abs(N-K)) cout << N << endl;
        else cout << abs(N-K) << endl;
        return 0;
    }
    
    int tmp = 0,MIN = 9223372036854775807;
    
    tmp = (N+K)/K;
    
    cout << min(abs((tmp*K)-N),abs((tmp-1)*K-N)) << endl;
    
    return 0;
}





Measured memory_bytes: 256
using System;

namespace AOJ.Volume2
{
    public class InterestRates
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                int y = int.Parse(Console.ReadLine());

                int ans = 0;
                decimal amount = 0;
                for(int i = 0; i < n; i++)
                {
                    var input = Console.ReadLine().Split(' ');
                    int rate = int.Parse(input[1]);
                    decimal tmp_amount;
                    if(input[2] == "1")
                    {
                        // ??????
                        decimal tmp = y * rate;
                        tmp = tmp / 100;
                        tmp_amount = 1 + tmp;
                    }
                    else
                    {
                        // ??????
                        double tmp = 100 + rate;
                        tmp = tmp / 100;
                        tmp_amount = (decimal)Math.Pow(tmp, y);
                    }
                    if (tmp_amount > amount)
                    {
                        amount = tmp_amount;
                        ans = int.Parse(input[0]);
                    }
                }

                Console.WriteLine(ans);
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9700
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
using namespace std;
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
// #define int long long

// bool compair(string &first, string &second ){
//     if()
// }

signed main(){
    string s;
    set<string>st;
    int K;
    cin>>s>>K;
    rep(i,s.size()){
        rep(j,K){
            //if(i+j < s.size()){
                st.insert(s.substr(i,j+1));
            //}
        }
    }
    int count = 0;
    for(auto& x:st ){
        count++;
        if(count == K){
            cout<<x<<endl;
            return 0;
        }
    }
    
    


    return 0;
}


Measured memory_bytes: 1664
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		String[] s = new String[n];
		int[] p = new int[n];
		int[] ans = new int[n];
		int sum = 0;
		for(int i = 0;i < n;i++){
			s[i] = saori.nextHayami();
			p[i] = saori.saori_hayami();
		}
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				if(i == j)continue;
				if(s[i].compareTo(s[j]) > 0){
					ans[i]++;
				} else if(s[i].equals(s[j])){
					if(p[i] < p[j]){
						ans[i]++;
					}
				}
			}
		}
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				if(i == ans[j]){
					System.out.println(j+1);
					break;
				}
			}
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21844
#include <stdio.h>
int main()
{
   long long  int x,i,j;
    scanf("%lld",&x);
    for(i=-200;i<=200;i++)
        for(j=-200;j<=200;j++){
                if(x==33)
                {
                    printf("2 -1\n");
                    return 0;
                }
    if(i*i*i*i*i-j*j*j*j*j==x){
        printf("%lld %lld\n",i,j);
return 0;
    }
}
}


Measured memory_bytes: 1728
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        double ans = 0;
        FOR(i,1,n+1) {
            int x = i;
            if (i >= k)
                ans += 1.0/n;
            else {
                double p = 1.0/n;
                while (x < k) {
                    x *= 2;
                    p *= 1.0/2;
                }
                ans += p;
            }                    
        }
        printf("%.10f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
bool b[8];
int main() {
	int n;
	cin >> n;
	int c=0,b[8]={};
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a>=3200)c++;
		else b[a/400]++;
	}
	int min=0;
	for(int i=0;i<8;i++){
		if(b[i])min++;
	}
	cout<<max(1,min)<<" "<<min+c<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  int pos = 0;
  cin >> S;
  while (pos <= S.length()) {
    if (S.compare(pos, 7, "dreamer") == 0) {
      pos = pos+7;
      if (S.compare(pos, 4, "aser") == 0) {
        pos = pos-2;
      } else 
      if (S.compare(pos, 3, "ase") == 0) {
        pos = pos-2;
      }
    } else
    if (S.compare(pos, 5, "dream") == 0) {
      pos = pos+5;
    } else
    if (S.compare(pos, 6, "eraser") == 0) {
      pos = pos+6;
      if (S.compare(pos, 4, "aser") == 0) {
        pos = pos-2;
      } else 
      if (S.compare(pos, 3, "ase") == 0) {
        pos = pos-2;
      }
    } else
    if (S.compare(pos, 5, "erase") == 0) {
      pos = pos+5;
      if (S.compare(pos, 5, "raser") == 0) {
        pos = pos-1;
      } else 
      if (S.compare(pos, 4, "rase") == 0) {
        pos = pos-1;
      }
    } else {
      break;
    }
    if (pos == S.length()) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}

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

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
const int MOD=1e9+7;

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	bool t=n!=1;
	cout<<t;
	return 0;
}


Measured memory_bytes: 3656
// https://atcoder.jp/contests/abc085/tasks/abc085_c
"use strict"
function Main(input) {
  const params = input.split(' ').map(Number);
  const n = params[0];
  const y = params[1];
  let total = 0;
  let existing = false;

  loop:
  for (let i = n; i>= 0; i--) {
    total = 10000 * i;
    if(total > y) continue;

    for (let j= n-i; j >= 0; j--){
      let k = n - i - j;
      total = 10000 * i + 5000 * j + 1000 * k;
      if(total === y) {
        console.log(`${i} ${j} ${k}`);
        existing = true;
        break loop;
      }
    }
  }

  if(!existing) {
    console.log('-1 -1 -1');
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(void){
  string vowel = "aeiou";
  char c;
  cin >> c;
  for(int i = 0; i < 5; ++i){
    if(c == vowel[i]){
      cout << "vowel" << endl;
      return 0;
	} else {
      
    }
  }
  cout << "consonant" << endl;
  return 0;
}

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

int main(){
   ll A, B, N;
   cin >> A >> B >> N;
   if(B > N) cout << A*N/B << endl;
   else cout << A*(B-1)/B << endl;
}

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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()
#define allpt_r(v) (v).rbegin(), (v).rend()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(vector<vector<T>> v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

class Unionfind
{
    vector<int> p;

public:
    int find(int x);
    void unite(int x, int y);
    Unionfind(int n);
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
}
int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
    }
}

void getpair(int &ans, const int m, vector<int> &v)
{
    int a;
    rep(i, m)
    {
        if (i == 0)
        {
            ans += v[i] / 2;
            v[i] = v[i] % 2;
        }
        else if (m % 2 == 0 && i == m / 2)
        {
            ans += v[i] / 2;
            v[i] = v[i] % 2;
        }
        else
        {
            a = min(v[i], v[m - i]);
            ans += a;
            v[i] -= a;
            v[m - i] -= a;
        }
    }
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, x, y, ans = 0;
    const int xmax = 100001;
    cin >> n >> m;
    VI histgram(xmax, 0), modhist(m, 0);
    rep(i, n)
    {
        cin >> x;
        histgram[x]++;
    }
    rep(i, xmax)
    {
        if (histgram[i] == 1)
        {
            histgram[i] = 0;
            modhist[i % m]++;
        }
        else if (i % m == 0)
        {
            modhist[i % m] += histgram[i];
            histgram[i] = 0;
        }
        else if (i % m == m / 2 && m % 2 == 0)
        {
            modhist[i % m] += histgram[i];
            histgram[i] = 0;
        }
        else if (histgram[i] % 2 == 1)
        {
            histgram[i]--;
            modhist[i % m]++;
        }
    }

    getpair(ans, m, modhist);

    rep(i, xmax)
    {
        if (modhist[m - (i % m)] > 0)
        {
            y = min(modhist[m - (i % m)], histgram[i]);
            histgram[i] -= y;
            modhist[m - (i % m)] -= y;
            ans += y;
        }
    }
    rep(i, xmax)
    {
        ans += histgram[i] / 2;
        histgram[i] -= (histgram[i] / 2) * 2;
    }
    cout << ans << rt;

    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
     int a, b;
     cin >> a >> b;
     string ret;
     if (a <= 0 && 0 <= b) ret = "Zero";
     else if (a > 0) ret = "Positive";
     else{
	  int range = b - a + 1;
	  if (range % 2 !=0) ret = "Negative";
	  else ret = "Positive";	 
	}
	cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int train[10];
int x,top,i;
while(scanf("%d",&x)!=EOF){
if(x==0){
printf("%d\n",top);
train[top-1]=0;
for(i=0;i<10;i++){
train[i]-=(train[i]!=0);
if(train[i]==1) top=i+1;
}
}else{
top=x;
for(i=0;i<10;i++){
train[i]+=train[i]!=0;
}
train[x-1]=1;
}
}
return 0;
}

Measured memory_bytes: 600
class Node():
    def __init__(self, id, key):
        self.id = id
        self.key = key

    def setKeys(self, data):
        length = len(data)
        if ( self.id // 2 ) != 0:
            self.pk = data[self.id // 2]
        else :
            self.pk = -1
        if self.id * 2 < length:
             self.lk = data[self.id * 2]
        else :
            self.lk = -1
        if self.id * 2 + 1 < length:
             self.rk = data[self.id * 2 + 1]
        else :
            self.rk = -1

    def printInfo(self):
        print( "node " + str(self.id) + ": key = " + str(self.key), end=", " )
        if self.pk != -1:
            print( "parent key = " + str(self.pk), end = ", ")
        if self.lk != -1:
            print( "left key = " + str(self.lk), end = ", ")
        if self.rk != -1:
            print( "right key = " + str(self.rk) , end=", ")
        print()

def main():
    n = int( input() )
    inputs = input().split()
    for tmp in inputs:
        tmp = int(tmp)
    data = [0]
    data.extend(inputs)
    Tree = []
    for i in range(1, n+1):
        Tree.append( Node(i, data[i]) )
    for node in Tree:
        node.setKeys( data )
        node.printInfo()

if __name__ == '__main__':
    main()



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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int sim(int a, int b, int c, int d, int ttl, int ua, int ub, int uc, int ud) {
    int bk = ua * 10 + ub * 50 + uc * 100 + ud * 500 - ttl;
    if (bk < 0) return 10000;

    a -= ua, b -= ub, c -= uc, d -= ud;
    if (bk / 500 && ud) return 10000;
    d += bk / 500; bk %= 500;
    if (bk / 100 && uc) return 10000;
    c += bk / 100; bk %= 100;
    if (bk / 50 && ub) return 10000;
    b += bk / 50; bk %= 50;
    if (bk / 10 && ua) return 10000;
    a += bk / 10;

    return a + b + c + d;
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;
    bool fst = true;

    while (true) {
        int ttl; cin >> ttl;
        if (!ttl) break;
        int a, b, c, d; cin >> a >> b >> c >> d;

        if (!fst) cout << endl;
        fst = false;

        int besta, bestb, bestc, bestd;
        int bestv = 1000;

        rep(i, 0, a + 1) rep(j, 0, b + 1) rep(k, 0, c + 1) rep(l, 0, d + 1) {
            int v = sim(a, b, c, d, ttl, i, j, k, l);
            // cout << i << " " << j << " " << k << " " << l << " " << v << endl;
            if (v < bestv)
                besta = i, bestb = j, bestc = k, bestd = l;
        }
        if (besta) cout << "10 " << besta << endl;
        if (bestb) cout << "50 " << bestb << endl;
        if (bestc) cout << "100 " << bestc << endl;
        if (bestd) cout << "500 " << bestd << endl;
    }    
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
template <typename T>
using vector2d = vector<vector<T>>;
using P = tuple<int, int, int>;

int dir[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};

bool range_check(int y, int x, int h, int w = -1) {
    if(w < 0) w = h;
    return (0 <= x && x < w && 0 <= y && y < h);
}


int main() {
    int H, W;
    cin >> H >> W;
    int ans = 0;
    vector2d<int> s(H, vector<int>(W));
    for(int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < W; j++) {
            s[i][j] = S[j] == '#';
            ans += S[j] == '.' ? 1 : 0;
        }
    }
    queue<P> q;
    q.emplace(0, 0, 1);
    while(!q.empty()) {
        int y, x, i;
        tie(y, x, i) = q.front(); q.pop();
        if(y == H - 1 && x == W - 1) {
            ans -= i;
            cout << ans << endl;
            return 0;
        }
        for(int d = 0; d < 4; d++) {
            int ny = y + dir[d][0], nx = x + dir[d][1];
            if(range_check(ny, nx, H, W) && !s[ny][nx]) {
                q.emplace(ny, nx, i + 1);
                s[ny][nx] = -1;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans = 1;
    if (N % 2) {
        ans = 0;
    } else {
        for (int i = 0; i < N/2; i++) {
            int j = i + N/2;

            if (S[i] - S[j]) ans = 0;
        }
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi a(n); fore(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    LL ans = 0;
    fore(i, 0, n) fore(j, i + 1, n) {
        ans += upper_bound(a.begin() + j + 1, a.end(), a[i] + a[j] - 1) - lower_bound(a.begin() + j + 1, a.end(), a[j] - a[i]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	long MOD = (long) (1e9 + 7);

	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int x = sc.nextInt();
		int y = sc.nextInt();
		ArrayList<Integer>[] list = new ArrayList[2];
		for (int i = 0; i < 2; ++i) {
			list[i] = new ArrayList();
		}
		int c = 0;
		boolean first = true;
		for (int i = 0; i < s.length(); ++i) {
			int j = i;
			int cnt = 0;
			while (j < s.length() && s.charAt(j) == 'F') {
				++cnt;
				++j;
			}
			if (first) {
				x = Math.abs(x - cnt);
				first = false;
			} else {
				list[c].add(cnt);
			}
			i = j;
			c ^= 1;
		}
		x = Math.abs(x);
		y = Math.abs(y);
		if (x > 8000 || y > 8000) {
			System.out.println("No");
			return;
		}
		boolean[][] dp = new boolean[2][8001];
		dp[0][0] = true;
		for (int i = 0; i < list[0].size(); ++i) {
			for (int j = 0; j <= 8000; ++j) {
				dp[(i % 2) ^ 1][j] = false;
			}
			for (int j = 0; j + list[0].get(i) <= 8000; ++j) {
				if (dp[(i % 2)][j]) {
					dp[(i % 2) ^ 1][j + list[0].get(i)] = true;
					dp[(i % 2) ^ 1][Math.abs(j - list[0].get(i))] = true;
				}
			}
		}
		if (!dp[list[0].size() % 2][x]) {
			System.out.println("No");
			return;
		}
		dp = new boolean[2][8001];
		dp[0][0] = true;
		for (int i = 0; i < list[1].size(); ++i) {
			for (int j = 0; j <= 8000; ++j) {
				dp[(i % 2) ^ 1][j] = false;
			}
			for (int j = 0; j + list[1].get(i) <= 8000; ++j) {
				if (dp[(i % 2)][j]) {
					dp[(i % 2) ^ 1][j + list[1].get(i)] = true;
					dp[(i % 2) ^ 1][Math.abs(j - list[1].get(i))] = true;
				}
			}
		}
		if (!dp[list[1].size() % 2][y]) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 27256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 100000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev=inf;
string s;
vector<int> v;

main(void){
	scanf("%lld",&n);
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			int at=i-1;
			at+=n/i-1;
			cev=min(cev,at);
		}
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    // your code goes here
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int d,t,s;
    cin>>d>>t>>s;
    int ti=(d/s)+(d%s!=0);
    cout<<(ti>t?"No":"Yes");
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
    #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--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

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

    int main()
    {
    int a,b;
    cin>>a>>b;
    int k;
    cin>>k;
    for(int i=a; i<=min(b,a+k-1); i++)
    {
        cout<<i<<endl;
    }
    for(int i=max(b-k+1,a+k); i<=b;i++)
    {
        cout<<i<<endl;
    }
    
    }


Measured memory_bytes: 256