akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};

int main(){
  int n, m, k;
  cin >> n >> m >> k;
 
  UnionFind uf(n);
  vector<set<int>> bo(n);
  vector<set<int>> f(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    f[a].insert(b);
    f[b].insert(a);
    uf.unite(a, b);
  }
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    bo[a].insert(b);
    if (!uf.same(a, b)) bo[a].erase(b);
    bo[b].insert(a);
    if (!uf.same(a, b)) bo[b].erase(a);
  }

  vector<int> res(n, 0);
  for (int i = 0; i < n; i++) {
   res[i] = uf.size(i) - 1 - f[i].size() - bo[i].size();
  }
  for (auto e : res) cout << e << " ";
  cout << endl;
  return 0; 
} 

Measured memory_bytes: 29696
n = int(input())
a = input()
list1 = list(map(int,a.split()))

cout = 0
coutmax = 0
for i in range(n-1):
    if list1[i+1] <= list1[i]:
        cout += 1
    else:
        if cout > coutmax :
            coutmax = cout
        cout = 0
    if i == n-2:
        if cout > coutmax :
            coutmax = cout
print(coutmax)

Measured memory_bytes: 17016
import java.util.*

fun main(args : Array<String>) {
    val Q = readLine()!!.toInt()

    val A = MedianManager(Q)
    var B = 0L
    // o(QlogQ)
    (1..Q).forEach {
        val query = readLine()!!
        if (query[0] == '1') {
            val (q, a, b) = query.split(" ").map { it.toLong() }
            // Should be O(logQ)
            A.add(a)
            B += b
        } else {
            // 求める
            // fx = sum(|x - ai|) + B
            // sum(|x -ai|)の最小値をとるx はai の中央値
            // Should be O(log1)
            val median = A.median()
            var sum = A.rightSum - A.leftSum + B
            if (!A.isBalanced()) {
                sum -= median
            }
            println(median.toString() + " " + sum.toString())
        }
    }
}

class MedianManager(size: Int) {
    private var leftPriorityQueue: PriorityQueue<Long> = PriorityQueue(size, Collections.reverseOrder())
    var leftSum = 0L
    private var rightPriorityQueue: PriorityQueue<Long> = PriorityQueue(size)
    var rightSum = 0L

    fun add(element: Long) {
        // Add element so that left.size <= right.size will be kept.
        if (leftPriorityQueue.size < rightPriorityQueue.size) {
            leftPriorityQueue.add(element)
            leftSum += element
        } else {
            rightPriorityQueue.add(element)
            rightSum += element
        }

        if (leftPriorityQueue.size == 0 || rightPriorityQueue.size == 0) {
            return
        }

        if (leftPriorityQueue.peek() > rightPriorityQueue.peek()) {
            val greaterElement = leftPriorityQueue.poll()
            leftSum -= greaterElement
            val smallerElement = rightPriorityQueue.poll()
            rightSum -= smallerElement


            rightPriorityQueue.add(greaterElement)
            rightSum += greaterElement

            leftPriorityQueue.add(smallerElement)
            leftSum += smallerElement
        }
    }

    fun median() : Long {
        if (leftPriorityQueue.size < rightPriorityQueue.size || leftPriorityQueue.size == 0) {
            return rightPriorityQueue.peek()
        }

        return leftPriorityQueue.peek()
        //return (leftPriorityQueue.peek() + rightPriorityQueue.peek()) / 2
    }

    fun isBalanced() : Boolean {
        return leftPriorityQueue.size == rightPriorityQueue.size
    }
}

Measured memory_bytes: 85996
#include <stdio.h>
const int MAX_V = 10000;
int prime[10000];
int main(){
int i, k, v ,n;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  while(scanf("%d", &n)){
    if(n==0)break;
    int fir=0 , sec=0;
    for(i=n ;i>3 ;i--){
      if(prime[i] && prime[i-2]){
        fir=i-2;
        sec=i;
        break;
      }
    }
    printf("%d %d\n" ,fir ,sec);
  }
  return 0;
}

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

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

    // string c = s[c];

    for (int i = 0; i < n; i++)
    {
        if(s[k-1] != s[i]){
            s[i] = '*';
        }
    }
    
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
num = list(map(int, input().split()))
sum=num[0]+num[1]
if num[2] <= num[0]:
    print(int(num[0] - num[2]), num[1])
elif num[2] > num[0]:
    if num[2] > sum:
        print(0, 0)
    else:
        print(0, sum - num[2])


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

using namespace std;

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

int in() { int x; scanf("%d", &x); return x; }
template<typename T> void pv(T a, T b) { for (T i = a; i < b; i++) cout << *i << ' '; cout << endl; }
template<typename T, typename U> void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void chmax(T &x, U y) { if (x < y) x = y; }

int N;
int a[100010];

int abs(int a, int b) {
  int c = a - b;
  return c < 0 ? -c : c;
}

int main() {
  int mx = 0;
  N = in();
  REP(i,N) {
    a[i] = in();
    chmax(mx, a[i]);
  }

  int res = 0;
  int dist = (1<<29);
  int mid = mx / 2;
  REP(i,N) if (a[i] != mx) {
    int t = abs(a[i] - mid);
    if (t < dist) {
      chmin(dist, t);
      res = a[i];
    }
  }

  cout << mx << ' ' << res << endl;

  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
//#define s second
#define MOD (long long)1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define nax (int)1e5+1
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		int n;
		cin>>n;
		if(n>9){
			int bound = 20;
			int previous =1;
			int ans = 9;
			while(n>bound){
				ans++;
				ans += previous*2;
				previous++;
				bound +=10;	
			}
			bound = bound -10;
			bound++;
			while(bound <= n){
				int first = bound%10;
				int last = bound;
				while(last>=10){
					last = last /10;
				}
				for(int i=1;i<=bound;i++){
					int temp_first = i%10;
					int temp_last = i;
					while(temp_last>=10){
						temp_last = temp_last/10;
					}
					if(temp_first == last && temp_last == first){
						ans += 2;
						if(i == bound){
							ans--;
						}
					}
				}
				bound++;
			}
			cout<<ans;
		}
		else{
			cout<<n;
		}
	} 
};
 
int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();
 
 return 0;
}

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

#define ODD  false
#define EVEN true

int main(void){
    std::string S;
    std::string ans = "Yes";
    char c;
    int s_length = 0;
    bool flag = ODD;
    std::cin >> S;
    

    s_length = (int)S.length();

    for(int i = 0; i < s_length; i++){
        c = S[i];
        if(flag == ODD){
            if(S[i] == 'L'){
                ans = "No";
            }
        }
        if(flag == EVEN){
            if(S[i] == 'R'){
                ans = "No";
            }
        }
        flag = !flag;
    }
    std::cout << ans;
    return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char


main = do
    n <- readLn
    as <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let v :: VU.Vector Int
        v = VU.create $ do
            v <- VUM.replicate n 0
            forM_ as $ \i -> do
                VUM.modify v ((+) 1) (i-1)
            return v
    mapM_ print $ VU.toList v

Measured memory_bytes: 9904
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;


int main()
{

        string a ; string b; cin >> a >> b;
        int a1 , b1; cin>>a1>>b1;
        string u = "";cin>>u;
        if(u == a)
            cout<<a1-1<<" "<<b1<<endl;
        else
            cout<<a1 << " "<<b1-1<<endl;



    return 0;
}


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


int main(){
    int num,tmp;
    int buff[100];

    scanf("%d",&num);

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

    for(int j,i=0;i<num;i++){
        tmp=buff[i];
        j=i-1;
        while(j>=0&&buff[j]>tmp){
            buff[j+1]=buff[j];
            j--;
        }
        buff[j+1]=tmp;
        for(int k=0;k<num;k++){
            if(k==num-1){
                printf("%d",buff[k]);
                continue;
            }
            printf("%d ",buff[k]);
        }
            printf("\n");
    }
    return 0;
}



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

int main()
{
	long long a, b, c, d;
  	long long P1, P2, P3, P4;
  
  	cin >> a >> b >> c >> d;
  
	P1 = a * c;
  	P2 = a * d;
  	P3 = b * c;
  	P4 = b * d;
  	cout << max(max(P1, P2), max(P3, P4)) << endl;
  	return 0;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int d1, d2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	d1 = max(x1-x2,x2-x1);
	d2 = max(y1-y2,y2-y1);
	int x3, y3, x4, y4;
	if (dx >= 0 && dy >= 0) {
		x3 = x2 - d2;
		y3 = y2 + d1;
		x4 = x3 - d1;
		y4 = y3 - d2;
	}
	if (dx >= 0 && dy <= 0) {
		x3 = x2 + d2;
		y3 = y2 + d1;
		x4 = x3 - d1;
		y4 = y3 + d2;
	}
	if (dx <= 0 && dy >= 0) {
		x3 = x2 - d2;
		y3 = y2 - d1;
		x4 = x3 + d1;
		y4 = y3 - d2;
	}
	if (dx <= 0 && dy <= 0) {
		x3 = x2 + d2;
		y3 = y2 - d1;
		x4 = x3 + d1;
		y4 = y3 + d2;
	}

	cout << x3 << " " << y3 << " " << x4 << " " << y4;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long tCookie = scan.nextLong();
		long aCookie = scan.nextLong();
		long count = scan.nextLong();
		scan.close();

		if (count <= tCookie) {
			tCookie -= count;
			System.out.println(tCookie + " " + aCookie);
			return;
		}

		if (tCookie + aCookie <= count) {
			System.out.println("0 0");
			return;
		}

		count -= tCookie;
		System.out.println("0 " + (aCookie - count));
	}
}


Measured memory_bytes: 22224
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;

int n, m;
vector<int> adj[N];
int dp[N];

void calc(int u, int p=-1) {
  ll ans = 1;
  for (int v : adj[u]) {
    if (v != p) {
      calc(v, u);
      ans = ans * (1 + dp[v]) % m;
    }
  }
  dp[u] = ans;
}

ll pans = 1;
void solve(int u, int p=-1) {
  vector<int> pref, suff;
  pref.push_back(1);
  for (int v : adj[u]) {
    if (v != p) {
      pref.push_back(1 + dp[v]);
      suff.push_back(1 + dp[v]);
    }
  }
  suff.push_back(1);
  for (int i = 1; i < pref.size(); i++) {
    pref[i] = (ll) pref[i] * pref[i-1] % m;
  }
  for (int i = (int) suff.size()-2; i >= 0; i--) {
    suff[i] = (ll) suff[i] * suff[i+1] % m;
  }
  dp[u] = pref.back() * pans % m;
  /*
  cerr << u << " -> " << pans << " " << dp[u] << nl;
  for (int i : pref) cerr << i << " "; cerr << nl;
  for (int i : suff) cerr << i << " "; cerr << nl;*/
  int i = 0;
  for (int v : adj[u]) {
    if (v != p) {
      ll prev = pans;
      pans = ((prev * pref[i] % m) * suff[i+1] + 1) % m;
      solve(v, u);
      pans = prev;
      i++;
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n-1; i++) {
    int u, v; cin >> u >> v; u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  calc(0);
  solve(0);
  for (int i = 0; i < n; i++) {
    cout << dp[i] << nl;
  }
  return 0;
}


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

namespace debug
{
    public static partial class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine().ToLong();
            var ais = Console.ReadLine().ToLongArray();
            var array = new bool[n];

            for (var i = n; i > 0; i--)
            {
                var sum = 0;
                var num = 1;
                while (num * i <= n)
                {
                    sum += array[num * i - 1] ? 1 : 0;
                    num++;
                }

                if (sum % 2 != ais[i - 1])
                {
                    array[i - 1] = true;
                }
            }

            Console.WriteLine(array.Count(x => x));
            if (array.Any(x => x))
            {
                Console.WriteLine(array.Select((x, idx) => new {x, idx}).
                                        Where(x => x.x).Select(x => x.idx + 1).JoinToStr(" "));
            }
        }
    }

    public static partial class Program
    {
        //テンプレここから
        private static long GCD(long aaa, long bbb) => bbb == 0 ? aaa : GCD(bbb, aaa % bbb);
        private static long LCM(long aaa, long bbb) => aaa * bbb / GCD(aaa, bbb);
        private static long ToLong(this double ddd) => (long) ddd;
        private static long ToLong(this string str) => long.Parse(str);
        private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
        private static long[] ToLongArray(this string str, char opr = ' ') => str.Split(opr).ToLong();
        private static long Diff(long aaa, long bbb) => Math.Abs(Math.Max(aaa, bbb) - Math.Min(aaa, bbb));
        private static long Sign(this long iii) => Math.Sign(iii);
        private static bool IsEven(this long iii) => iii % 2 == 0;
        private static readonly int[] Dx = {0, -1, 0, 1};
        private static readonly int[] Dy = {-1, 0, 1, 0};
        public const int MOD = 1000000007;
        public const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const string alphabet = "abcdefghijklmnopqrstuvwxyz";
        public static long ToLong(this char ccc) => ccc.ToString().ToLong();
        public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
        public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

        public static string JoinToStr(this IEnumerable<long> array, string sep = "")
            => array.Select(xxx => xxx.ToString()).Join(sep);

        public static string JoinToStr(this IEnumerable<int> array, string sep = "")
            => array.Select(xxx => xxx.ToString()).Join(sep);

        //テンプレここまで
    }
}

Measured memory_bytes: 31452
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll a;
	double b;
	cin>>a>>b;
	ll b1=(ll)(b*100+0.5);
	cout<<a*b1/100<<endl;
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)

typedef long long ll;


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

int main() {
  int n;
  cin >> n;
  
  int fact = 1;
  vector<int> perm(n);
  for (int i = n; i > 0; i--)
  {
      perm[i-1] = i;
      fact *= i;
  }

//   rep(i, n) cout << perm[i] << " orig" << endl;

  vector<int> p(n), q(n); 
  rep(i, n) {
      cin >> p[i];
  }
  rep(i, n) {
      cin >> q[i];
  }

  int perm_count = 1; int count_p = 0; 
  do 
  {
      int count = 0;
      for (int i = 0; i < n; i++)
      {
          /* code */
          if (perm[i] == p[i]) count++;
      }

      if (count == n)
      {
          /* code */
          count_p = perm_count;
          break;
      }
    //   cout << perm_count << " ";
      perm_count++;
  } while (next_permutation(perm.begin(), perm.end()));

  for (int i = n; i > 0; i--)
  {
      perm[i-1] = i;
  }
  
  perm_count = 1; int count_q = 0;
  do
  {
      int count = 0;
      for (int i = 0; i < n; i++)
      {
          /* code */
          if (perm[i] == q[i]) count++;
      }

      if (count == n)
      {
          /* code */
          count_q = perm_count;
          break;
      }
      perm_count++;
  } while (next_permutation(perm.begin(), perm.end()));

  cout << abs(count_p - count_q) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> b(n);
    ll sum = 0;
    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        a[i + 1] = seinomi(a[i + 1] - seinomi(b[i] - a[i]));
        a[i] = seinomi(a[i] - b[i]);
    }
    ll newsum = 0;
    for (int i = 0; i < n + 1; i++)
    {
        newsum += a[i];
    }
    cout << sum - newsum << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(){
    char s[11], t[12];
    if(scanf("%s%s", s, t)){
        if(strlen(t) != strlen(s) + 1){
        printf("No");
        return 0;
    }
    t[strlen(t) - 1] = '\0';
    if(strcmp(s, t) != 0){
        printf("No");
        return 0;
    }
    printf("Yes");
    return 0;
    }
}

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


int main(){
  int H, A;
  cin >> H >> A;

  int count = 0;
  int damage = 0;
  while(damage < H){
    damage += A;
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long[] x = new long[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 1; i < n; i++) {
			if ((x[i] - x[i - 1]) * a > b) {
				ans += b;
			} else {
				ans += (x[i] - x[i - 1]) * a;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define INF 100000000

struct P {
    int from;
    int used;
    double cost;

    bool operator >(const P& p) const {
        return cost > p.cost;
    }
};

struct Edge {
    int to, cost;
};

double G[30][256];

int main() {
    int ticket_n, town_n, road_n, start, goal;
    while (cin >> ticket_n >> town_n >> road_n >> start >> goal, ticket_n|town_n|road_n|start|goal) {
        start--;
        goal--;
        vi tickets(ticket_n);
        REP(i, ticket_n) cin >> tickets[i];
        vector<vector<Edge>> E(town_n);
        REP(i, road_n) {
            int x, y, z;
            cin >> x >> y >> z;
            x--;
            y--;
            E[x].push_back({y, z});
            E[y].push_back({x, z});
        }

        fill_n((double *)G, 30*256, INF);

        priority_queue<P, vector<P>, greater<P>> que;
        que.push({start, 0, 0});
        G[start][0] = 0;
        while (!que.empty()) {
            P p = que.top(); que.pop();
            if (p.from == goal) {
                printf("%.3f\n", p.cost);
                goto END;
            }

            for (Edge e : E[p.from]) {
                REP(i, ticket_n) {
                    if (!BIT(p.used, i)) {
                        int used = p.used | (1 << i);
                        double cost = p.cost + e.cost/(double)tickets[i];
                        if (G[e.to][used] > cost) {
                            G[e.to][used] = cost;
                            que.push({e.to, used, cost});
                        }
                    }
                }
            }
        }
        cout << "Impossible" << endl;
END: {}
    }
}

Measured memory_bytes: 4652
#include <stdio.h>
int main(){
  int a,i,j,x,N[4][13]={};
  char ch;

  scanf("%d\n",&a);
  for(i = 0;i < a;i++){
    scanf("%c %d\n",&ch,&x);

    if(ch == 'S') N[0][x-1] = x;
    if(ch == 'H') N[1][x-1] = x;
    if(ch == 'C') N[2][x-1] = x;
    if(ch == 'D') N[3][x-1] = x;
    
  }
  for(j = 0;j < 13 ;j++){
    if (N[0][j] == 0) printf("S %d\n",j+1);
  }
  for(j = 0;j < 13 ;j++){
    if (N[1][j] == 0) printf("H %d\n",j+1);
  }
  for(j = 0;j < 13 ;j++){
    if (N[2][j] == 0) printf("C %d\n",j+1);
  }
  for(j = 0;j < 13 ;j++){
    if (N[3][j] == 0) printf("D %d\n",j+1);
  }
  return 0;
}



Measured memory_bytes: 2044
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

int n, a;
int[] x;

void main() {
    scan(n, a);
    x = readln.split.to!(int[]);

    auto dp = new long[][][](n + 1, n + 1, 2500 + 1);
    dp[0][0][0] = 1;

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. n + 1) {
            foreach (k ; 0 .. 2500 + 1) {
                if (dp[i][j][k] == 0) continue;
                dp[i + 1][j][k] += dp[i][j][k];
                dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
            }
        }
    }

    long ans;

    foreach (j ; 1 .. n + 1) {
        ans += dp[n][j][j * a];
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main() {
	long long k;cin>>k;
	long long n=50;
	long long a[n];
	for(int i=0;i<n;i++){
		a[i]=49+k/n-k%n;
	}
	for(int i=0;i<k%n;i++){
		a[i]+=51;
	}
	cout<<n<<endl;
	for(int i=0;i<n;i++){
		cout<<a[i]<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string K;
    cin >> K;
    ll D;
    cin >> D;  
    ll n=K.size();
    //dp[i][j]はK[i]まで見て、余りがjであるもの
    vector<vector<ll>> dp0(n, vector<ll>(D, 0));
    vector<vector<ll>> dp1(n, vector<ll>(D, 0));
    vector<ll> k(n,0);
    for(ll i=0;i<n;++i){
        k[i]=K[i]-'0';
    }
    for(ll i=0;i<k[0];++i)dp1[0][i%D]++;
    dp0[0][k[0]%D]++;
    for(ll i=1;i<n;++i){
        for(ll j=0;j<D;++j){
            for(ll l=0;l<10;++l){
            if(l<k[i]){
                dp1[i][(j+l)%D]+=dp0[i-1][j]+dp1[i-1][j];
            }
            else if(l==k[i]){
                dp0[i][(j+l)%D]+=dp0[i-1][j];
                dp1[i][(j+l)%D]+=dp1[i-1][j];
            }
            else {
                dp1[i][(j+l)%D]+=dp1[i-1][j];
            }
            dp0[i][(j+l)%D]%=MOD;
            dp1[i][(j+l)%D]%=MOD;
            }
        }   
    }
    prt((dp0[n-1][0]+dp1[n-1][0]-1+MOD)%MOD)


    return 0;
}


Measured memory_bytes: 16768
import collections

n = int(input())
n_half = int(n / 2)
v = list(map(int, input().split()))

odd = []
even = []
for i in range(n_half):
  odd.append(v[i*2])
  even.append(v[i*2+1])

oc = collections.Counter(odd)
ec = collections.Counter(even)
ocm = oc.most_common()
ecm = ec.most_common()
if ocm[0][0] != ecm[0][0]:
  print(n - ocm[0][1] - ecm[0][1])
else:
  if ocm[0][1] == n_half and ecm[0][1] == n_half:
    print(n_half)
  elif ocm[0][1] == n_half:
    print(n_half - ecm[1][1])
  elif ecm[0][1] == n_half:
    print(n_half - ocm[1][1])
  else:
    print(min(n - ocm[0][1] - ecm[1][1], n - ocm[1][1] - ecm[0][1]))


Measured memory_bytes: 65516
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<long long int>dp(M + 1);
	for (int i = 0; i < N; i++) {
		cin >> K >> L;
		for (int j = M; j >= K; j--) {
			dp[j] = max(dp[j], dp[j - K] + L);
		}
	}
	cout << dp.back() << endl;
	return 0;
} 

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
nodes = [[] for i in range(N)]
edges = {}
for i in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)
    edges[(a, b)] = i

# DFSで木の走査(開始位置はどこでもいい)
# (自分, 親, 親との辺の色)
stack = [(0, -1, -1)]
mx = 0
ans = [0] * (N-1)
while stack:
    u, prev, used = stack.pop()
    color = 0
    # 自分の子ノードを順番に塗り進めていく
    for v in nodes[u]:
        if v == prev:
            continue
        color += 1
        # 親-自分間で使用済の色だったら1つ進める
        if color == used:
            color += 1
        a, b = min(u, v), max(u, v)
        i = edges[(a, b)]
        ans[i] = str(color)
        stack.append((v, u, color))
    # 各ノードから使った色数の最大を取る
    mx = max(mx, color)

print(mx)
print('\n'.join(ans))


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}


vector<int> plist;
bool IsPrime(ll x){
  for(auto e:plist){
    if(e*e>x)break;
    if(x%e==0)return false;
  }
  return true;
}

void Mkplist(){
  plist.push_back(2);
  for(int i = 3; i < 1010; ++i){
    if(IsPrime(i))plist.push_back(i);
  }
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  modint& operator+=(const modint&b)
  {    return (*this) = (*this) + b;  }
  modint& operator-=(const modint&b)
  {    return (*this) = (*this) - b;  }
  modint& operator*=(const modint&b)
  {    return (*this) = (*this) * b;  }
  modint& operator/=(const modint&b)
  {    return (*this) = (*this) / b;  }
  modint& operator++()
  {    (*this)+=1; return (*this);  }
  modint& operator--()
  {    (*this)-=1; return (*this);  }
  modint operator++(int){
    modint tmp(*this);
    ++(*this);
    return tmp;
  }
  modint operator--(int){
    modint tmp(*this);
    --(*this);
    return tmp;
  }    
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x; is >> x;
    a = x;
    return is;
  }
};


int main(){
  Mkplist();
  int n;
  cin >> n;
  const ll mod = 7 + (1e+9);
  map<int,modint<mod>> st;
  for(int i = 2; i <= n; ++i){
    int j = i;
    while(j!=1){
      for(auto e:plist){
	while(j%e==0){
	  st[e]++;
	  j/=e;
	}
      }      
    }
  }
  modint<mod> ans = 1;
  for(auto e:st){
    ans *= (e.second+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
S = []
for _ in range(N):
    A = int(input())
    s = []
    for _ in range(A):
        x, y = map(int, input().split())
        s.append((x, y))
    S.append(s)

Ps, ans = itertools.product([0, 1], repeat=N), 0
for P in Ps:
    right = True
    for i, p in enumerate(P):
        if p == 1:
            for x, y in S[i]:
                if (y == 1 and P[x - 1] == 0) or (y == 0 and P[x - 1] == 1):
                    right = False
    if right:
        ans = max(ans, sum(P))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

void solve(long long X, long long A, long long B)
{
    if (B <= A)
    {
        cout << "delicious" << endl;
    }
    else if (B - A <= X)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }
}

int main()
{
    long long X;
    scanf("%lld", &X);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(X, A, B);
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,M;
    cin>>N>>M;
    int ans=0;
    rep(i,M){
        int a;cin>>a;
        if(a>M)ans++;
    }

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



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

typedef long long LL;

const int N=1000000;

char s[N+9];
int n;

void into(){
  scanf("%s",s+1);
  n=strlen(s+1);
}

void Get_s0(){
  int lst=0;
  for (int i=1;i<=n;++i)
	if (s[i]^'0') s[++lst]=s[i];
  n=lst;
}

void Debug(){
  return;
  for (int i=1;i<=n;++i)
	putchar(s[i]);
  puts("");
}

int cnt[5];
char c[5];

void Get_s(){
  int lst=0;
  for (int i=1;i<=n;++i)
	if (s[i]^s[lst]) s[++lst]=s[i];
  n=lst;
  for (int i=1;i<=n;++i) ++cnt[s[i]-'A'];
  for (int i=0;i<3;++i) c[i]='A'+i;
  if (cnt[0]>cnt[1]) swap(c[0],c[1]),swap(cnt[0],cnt[1]);
  if (cnt[0]>cnt[2]) swap(c[0],c[2]),swap(cnt[0],cnt[2]);
  if (cnt[1]>cnt[2]) swap(c[1],c[2]),swap(cnt[1],cnt[2]);
  //printf("%c %d\n%c %d\n%c %d\n",c[0],cnt[0],c[1],cnt[1],c[2],cnt[2]);
  Debug();
  for (int i=1;i<=n;++i)
	if (cnt[2]>cnt[1]&&s[i]==c[2]&&(i==1||i==n||(s[i-1]==c[0]||s[i+1]==c[0])&&s[i-1]^s[i+1])) s[i]='0',--cnt[2];
  Get_s0();
  Debug();
  for (int i=1;i<=n;++i)
	if (cnt[2]>cnt[1]&&s[i]==c[2]&&s[i-1]==c[0]&&s[i+1]==c[0]) s[i]='0',--cnt[2],--cnt[0];
  for (int i=1;i<=n;++i)
	if (s[i]=='0') s[i-1]='0';
  Get_s0();
  Debug();
  int now=1;
  for (int i=2;i<=n;++i){
	if (s[i]==c[1]&&s[i-1]==c[2]||s[i]==c[2]&&s[i-1]==c[1]){
	  if (cnt[1]>cnt[0]&&now) s[i]=s[i-1]='0',--cnt[1],--cnt[2];
	  now=1;
	}
	if (s[i]==c[0]) now=0;
  }
  Get_s0();
}

void work(){
  Get_s();
}

void outo(){
  for (int i=1;i<=n;++i)
	putchar(s[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4744
N, M = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i).sort.reverse
all = A.inject(:+)

count = 0

A.each do |a|
    if a >= all.quo(4 * M)
        count += 1
    end
    if count == M
        break
    end
end

if count == M 
    puts "Yes"
else
    puts "No"
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,30){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int N=2e6+5;
const int MD=1e9+7;
void add(int &x,int y) {
	x+=y;
	if(x>=MD) x-=MD;
	if(x<=0) x+=MD;
}
int f[N],inv[N];
int quick_pow(int x,int y) {
	int ans=1;
	while(y) {
		if(y&1) ans=1LL*ans*x%MD;
		y>>=1;
		x=1LL*x*x%MD;
	}
	return ans;
}
void init() {
	f[0]=1;
	for(int i=1;i<N;i++) f[i]=1LL*f[i-1]*i%MD;
	inv[N-1]=quick_pow(f[N-1],MD-2);
	for(int i=N-2;i>=0;i--) inv[i]=1LL*inv[i+1]*(i+1)%MD;
}
int cal(int x,int y) {
	return 1LL*f[x+y+2]*inv[x+1]%MD*inv[y+1]%MD;
}
int main() {
	init();
	int r1,c1,r2,c2;
	scanf("%d%d%d%d",&r1,&c1,&r2,&c2),r1--,c1--;
	int ans=0;
	add(ans,cal(r2,c2)),add(ans,cal(r1,c1));
	add(ans,-cal(r1,c2)),add(ans,-cal(r2,c1));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 15872
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    p = [int(i) for i in input().split()]
    f = p[0]
    s = p[1]
    ans = 0
    for i in range(2, len(p)):
        if (f < s and s < p[i]) or (f > s and s > p[i]):
            ans += 1
        f = s
        s = p[i]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38460
s = [len(x) for x in input().split('T')]
x, y = map(int, input().split())

X = set([s[0]])
Y = set([0])

for dx in s[2::2]:
    tX = set()
    for Xi in X:
        tX.add(Xi-dx)
        tX.add(Xi+dx)
    X = tX

for dy in s[1::2]:
    tY = set()
    for Yi in Y:
        tY.add(Yi-dy)
        tY.add(Yi+dy)
    Y = tY

if x in X and y in Y:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 48988
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import math


# In[14]:


N = int(input())


# In[15]:


for x in range(1,int(math.sqrt(N)+1))[::-1]:
    if N%x == 0:
        print((x-1)+(N//x-1))
        break


# In[ ]:






Measured memory_bytes: 9028
import java.awt.List;
import java.io.*;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] arr = new int[10];
		for (int i = 0; i < 10; i++) {
			String str;
			str = br.readLine();
			arr[i] = Integer.parseInt(str);
		}
		Arrays.sort(arr);
		for (int i = 9; i > 6; i--)
			System.out.println(arr[i]);
	}
}

Measured memory_bytes: 16864
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {

	int n, i;

	cin >> n >> i;

	cout << n - i + 1 << endl;



	return 0;
}

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

using namespace std;

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

    for (int i = 1; i < 50000; i++) {
        double tmp = i * 1.08;
        if ((long long)tmp == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    UnionFind tree(N);

    vector<vector<ll>> block(N),fri(N);
    rep(i,0,M){
        ll a,b;
        cin>>a>>b;
        tree.merge(a-1,b-1);
        fri[a-1].PB(b-1);
        fri[b-1].PB(a-1);
    }
    rep(i,0,K){
        ll a,b;
        cin>>a>>b;
        block[a-1].PB(b-1);
        block[b-1].PB(a-1);
    }
    rep(i,0,N){
        ll sum=tree.size(i)-1;
        rep(j,0,block[i].size()){
            if(tree.issame(i,block[i][j])){
                sum--;
            }
        }
        rep(j,0,fri[i].size()){
            if(tree.issame(i,fri[i][j])){
                sum--;
            }
        }
        cout<<sum<<" ";
    }
    return 0;
}

Measured memory_bytes: 14452
#include <bits/stdc++.h>  // ver2.2.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0 * 10^18 (MAXの1/3くらい)
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,m;
  cin >> n;
  Vi a(n);
  Vin(a);
  cin >> m;
  int qw,ans=0;
  rep(i,0,m){
    cin >> qw;
    if(count(ALL(a), qw)>0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3204
#include <stdio.h>
#define END_FLAG 255
static unsigned
char *c_read(void)
{
	static char s[2];
	fgets(s,2,stdin);
	if (feof(stdin)) *s=END_FLAG;
	return s;
}
int main(void) 
{
	unsigned char ch;
	unsigned counter[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	
	while (END_FLAG != (ch = * c_read()))
	{
		if ('a'<=ch && ch<='z') *(counter +ch -'a') += 1;
		if ('A'<=ch && ch<='Z') *(counter +ch -'A') += 1;
	}
	
	for(ch =0; ch < 26; ch++) fprintf(stdout,"%c : %u\n",ch+'a',*(counter +ch));
	return 0;
}

Measured memory_bytes: 524