akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 1e5+5;
int N, K;
string s;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> K >> s;
    int pt = 0;
    while (K--) {
        if (pt >= N-1) break;
        while (pt + 1 < N && s[pt+1] == s[pt]) pt++;

        char orig = s[pt];
        int start = pt+1;
        pt = start;
        while (pt+1 < N && s[pt+1] == s[pt]) pt++;
        for (int j = start; j <= pt; j++) {
            s[j] = orig;
        }
        //cout << K << ": " << s << '\n';
    }
    int sum = 0;
    for (int i = 1; i < N; i++) {
        if (s[i] == s[i-1]) sum++;
    }
    cout << sum << '\n';
}



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

typedef long long ll;
typedef long double ld;

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

    ll N;
    cin >> N;

    ll ans;

    for(ll i = 1; i * i <= N; i++) {
        if(N % i == 0) {
            ans = N / i;
        }
    }

    cout << ll(log10(ans)) + 1LL << endl;
}

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

int main(){
    int n;
    double sum=0;
    cin>>n;
    rep(i,n) {
        int a;
        cin>>a;
        sum+=1.0/a;
    }
    double ans=1.0/sum;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    Console.WriteLine(i.ToString()+"x"+j.ToString()+"="+(i*j).ToString());
                }
            }
        }
    }
}

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)

bool chk_array(VI array_1, VI array_2, int n){
    REP(i,n)
    {
        if( array_1.at(i) != array_2.at(i) )
        {
            //cout << "false!!" << endl;
            return false;
        }
    }
    //cout << "true!!" << endl;
    return true;
}
int main(void){
    int N;
    cin >> N;

    VI arrayP(N);
    VI arrayQ(N);
    REP(i,N){
        cin >> arrayP.at(i);   
    }
    REP(i,N){
        cin >> arrayQ.at(i);
    }

    //0～N-1を並べた順列作成
    VI junretsu(N);
    iota(junretsu.begin(), junretsu.end(), 1);
    int P_num = 0;
    int Q_num = 0;
    int num = 0;
    //next_permutation関数で全通り試し、辞書順で小さい方から何番目か計算する
    do
    {
        if( chk_array( junretsu, arrayP, N ) ) P_num = num;
        if( chk_array( junretsu, arrayQ, N ) ) Q_num = num;
        num ++;
    } while (next_permutation(junretsu.begin(), junretsu.end()));

    cout << abs( P_num - Q_num ) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	ans := (N-K+K-2)/(K-1) + 1
	fmt.Println(ans)
}


Measured memory_bytes: 5504
function main(input) {
  input=input.trim();
  const d = parseInt(input.split(" ")[0], 10);
  const n = parseInt(input.split(" ")[1], 10);
  if(d==0){
    if(n==100){
      console.log(101);
    }else{
      console.log(n);
    }
  }else if(d==1){
    if(n==100){
      console.log(10100);
    }else{
      console.log(n*100);
    }
  }else{
    if(n==100){
      console.log(1010000);
    }else{
      console.log(n*10000);
    }
    
  }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 20936
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll s;
  cin >> s;
  ll a1 = 1000000000;
  ll a2 = 1;
  ll c1 = 0;
  ll c2 = 0;
  ll b2 = CEIL(s, 1000000000);
  ll b1 = a1 * b2 - s;
  cout << a1 << " " << a2 << " " << b1 << " " << b2 << " " << c1 << " " << c2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
 
using namespace std;
int MOD = 1000000007;
signed main(){
    string s,t;
    cin >> s >> t;
    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    int d = 0;
    for(int i = s.size()-t.size();i >= 0;i--){
        int c = 1;
        for(int j = 0;j < t.size();j++){
            if(t[j] != s[i+j] && s[i+j] != '?')c = 0;
        }
        if(c == 1 && d == 0){
            d = 1;
            for(int j = 0;j < t.size();j++){
                s[i+j] = t[j];
            }
        }
    }
    if(d == 0){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    rep(i,s.size()){
        if(s[i] == '?')s[i] = 'a';
    }
    cout << s << endl;


    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc076.contest.atcoder.jp/tasks/abc076_c
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long x;
  cin >> x;
  long long cnt = 0LL;
  for(long long i = 1LL; i <= x; i++){
    cnt += i;
    if(cnt >= x){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
  int64_t N;
  cin >> N;
  vector<char> A;
  while (N>0){
    A.push_back('a'+(N-1)%26);
    N--;
    N/=26;
  }
  reverse(A.begin(), A.end());
  int len=A.size();
  for (int i=0; i<len; i++){
    cout << A.at(i);
  }
  cout << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n+10), y(n+10);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.begin() + n);

    int m_idx = n / 2;
    
    for (int i = 0; i < n; i++) {
        if (x[i] >= y[m_idx]) cout << y[m_idx - 1] << endl;
        else cout << y[m_idx] << endl;
    }

}

Measured memory_bytes: 4792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector<ll> solve(const vector<ll>& a, int n) {
  vector<ll> ans;
  ll i = 0;
  ll j = 0;
  while (n) {
    ans.push_back(a[i] + 12*j);
    ++i;
    if (i == 8) {
      i = 0;
      ++j;
    }
    --n;
  }
  return ans;
}

const vector<ll> even = { 2, 10, 3, 9, 4, 8, 6, 12 };
const vector<ll> odd  = { 6, 2, 10, 3, 9, 4, 8, 12 };;

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }

  vector<ll> ans;
  // Here, n >= 4
  if (n % 2 == 1) { // odd
    ans = solve(odd, n);
  } else { // even
    ans = solve(even, n);
  }

  rep(i, n) {
    cout << ans[i];
    if (i < n-1) {
      cout << " ";
    }
  }
  cout << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll A, B, C; cin >> A >> B >> C;
  ll result = 0;
  if (A%2==0||B%2==0||C%2==0) result = 0;
  else result = min(A*B, min(B*C, A*C) );
  cout << result << endl;
  return 0;
}

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1e5 + 5;
pair<int, int> arr[N];
int pre[N], suf[N];

int len(int l, int r)
{
	if (l > r) return 0;
	return r - l + 1;
}

int main()
{
	int n = read();
	for (int i = 1; i <= n; ++i) arr[i] = {read(), read()};
	sort(arr + 1, arr + n + 1);
	
	pre[0] = suf[n + 1] = 1e9;
	for (int i = 1; i <= n; ++i) pre[i] = min(pre[i - 1], arr[i].second);
	for (int i = n; i >= 1; --i) suf[i] = min(suf[i + 1], arr[i].second);
	
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		ans = max(ans, len(arr[i].first, arr[i].second) 
					 + len(arr[n].first, min(pre[i], suf[i])));
	for (int i = 1; i < n; ++i)
		ans = max(ans, len(arr[i].first, pre[i])
					 + len(arr[n].first, suf[i + 1]));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

#define MAX_PERSON (1000)

using namespace std;

void judge_grade(int m, int f, int r);

int main(void)
{
    int size;
 
    int* m = new int[MAX_PERSON + 1];
    int* f = new int[MAX_PERSON + 1];
    int* r = new int[MAX_PERSON + 1];
           
    for (int i = 0; i < MAX_PERSON + 1; i++) {        
         do {
             cin >> m[i] >> f[i] >> r[i];	     
         } while (((m[i] < 0 || m[i] > 50) || (f[i] < 0 || f[i] > 50) || (r[i] < 0 || r[i] > 100)) &&
		    !(m[i] == -1 || f[i] == -1 || r[i] == -1));		  

         if (m[i] == -1 && f[i] == -1 && r[i] == -1) {
             size = i;
	     break;
         }
    }
                   
    for (int i = 0; i < size; i++) {
         judge_grade(m[i], f[i], r[i]);         
    }
    
    delete[] m;
    delete[] f;
    delete[] r;
   
    return (0);
}

void judge_grade(int m, int f, int r)
{
     if (m == -1 || f == -1) {
         cout << "F" << endl;         
     } else if (m + f >= 80) {
         cout << "A" << endl;
     } else if (m + f >= 65 && m + f < 80) {
         cout << "B" << endl;
     } else if (m + f >= 50 && m + f < 65) {
         cout << "C" << endl;
     } else if (m + f >= 30 && m + f < 50) {
         if (r >= 50) {
	     cout << "C" << endl;
         } else {
	     cout << "D" << endl;
         }
     } else {
         cout << "F" << endl;
     }
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back



int main() {
	char in;
	cin >> in;
	if(in>='A' && in <='Z'){
		cout << "A" <<endl;
	}
	else if (in>='a' && in <='z')
	{
		cout << "a" <<endl;
	}

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int v, e;
   std::cin >> v >> e;
   std::vector<Int> ss(e), ts(e);
   rep(i, e) std::cin >> ss[i] >> ts[i];
   std::vector<std::vector<Int>> nexts(v);
   rep(i, e) {
      Int s = ss[i], t = ts[i];
      nexts[t].emplace_back(s);
      nexts[s].emplace_back(t);
   }
   std::vector<Int> xs(v, -1);
   xs[0] = 0;
   std::vector<Int> ys(v, 0);
   Int id = 1;
   std::vector<bool> zs(v);
   std::function<Int(Int,Int)> dfs = [&](Int i, Int prev) {
      xs[i] = id;
      id += 1;
      Int res = 0;
      Int c = 0;
      for(Int k : nexts[i]) {
         guard( k != prev );
         if( xs[k] == -1 ) {
            c += 1;
            ys[i] = 0;
            Int t = dfs(k, i);
            if( t + ys[i] == 0 and i != 0 ) {
               zs[i] = zs[i] or nexts[i].size() >= 2;
               // zs[k] = zs[k] or nexts[k].size() != 1;
            }
            res += t + ys[i];
         }
         else if( xs[k] < xs[i] ) {
            res += 1;
            ys[k] -= 1;
         }
      }
      // res += ys[i];
      fprintf(stderr, "i=%ld, res=%ld\n", i, res);
      if( i == 0 and c >= 2 ) zs[0] = true;
      return res;
   };
   dfs(0, -1);
   rep(i, v) {
      if( zs[i] ) printf("%ld\n", i);
   }
}



Measured memory_bytes: 6676
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string s;
    cin >> s;
    cout << *s.begin() << s.size() - 2 << *s.rbegin() << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            if (s == t.Substring(0, t.Length - 1))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 25892
n = int(input())
s = input()
a = set()
a1 = []
for i in range(n-2):
  if s[i] in a1:
    continue
  a1.append(s[i])
  a2 = []
  for j in range(i+1,n-1):
    if s[j] in a2:
      continue
    a2.append(s[j])
    a = a|set([s[i]+s[j]+k for k in set(list(s[j+1:]))])
print(len(a))

Measured memory_bytes: 3472
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
typedef long long ll;
const int inf=1<<30;
const double pi=acos(-1);

double n;

int main(){
	cout<<shosu(9);
	while(cin>>n){
		vector<double> num(10);
		double ans=0;
		num[0]=n;
		for(int i=1;i<10;i++){
			if(i%2) num[i]=num[i-1]*2;
			else num[i]=num[i-1]/3;
		}
		for(int i=0;i<10;i++){
			ans+=num[i];
		}
		cout<<ans<<endl;
	}
}

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

int main(){
  long long int N,M,ans=0;
  cin>>N>>M;
  long long int kara = M/N;
  for(int i=kara;i>=1;i--){
    if(M%i==0){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
S = input()
K = int(input())
l = []
cnt = 1
for i in range(1, len(S)):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        l.append(cnt)
        cnt = 1
l.append(cnt)

if len(l) == 1:
    print(len(S) * K // 2)
else:
    if S[0] == S[-1]:
        ans = sum([x // 2 for x in l]) * K
        ans -= (l[0] // 2 + l[-1] // 2 - (l[0] + l[-1]) // 2) * (K - 1)
    else:
        ans = sum([x // 2 for x in l]) * K
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++)
		cin >> a[i] >> b[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());

	if(n%2==1)
		cout << b[n/2]-a[n/2]+1 << endl;
	else
		cout << ((b[n/2-1]+b[n/2])-(a[n/2-1]+a[n/2]))+1 << endl;




}

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, c, d;
  cin >> A >> B;
  c = B - A+1;
  d = 0;
  for (int i =0 ; i <c ; i++) {
  if (A/10000 ==  A%10 && (A%10000-A%1000)/1000 == (A%100-A%10)/10){
  d++;
  }
  A++;
 } 
  cout << d << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var ans = (AB[0] + AB[1]) / 2.0;
            Console.WriteLine(ans == (int)ans ? ((int)ans).ToString() : "IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  priority_queue <int, vector<int>, greater<int> > pq;
  for(int i=0;i<n;i++){
    int ele;
    cin>>ele;
    pq.push(ele);
  }
  int ans=0;
  for(int i=0;i<k;i++){
    int p=pq.top();
    ans=ans+p;
    pq.pop();
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3728
#include <iostream>
using namespace std;
int main() {
    int w,h,n;  //四角形の横幅、縦幅、ピンの数
    int pinx[100],piny[100],pina[100];  //ピンの座標、塗りつぶしの種類
    /* ぬりつぶしについて
     * a = 1:指定された座標の左側すべて
     * a = 2:指定された座標の右側すべて
     * a = 3:指定された座標の上すべて
     * a = 4:指定された座標の下側すべて*/
    cin >> w >> h >> n;
    int reac[w][h]; //ぬりつぶす→0から1へ
    for (int k = 0; k <w ; ++k) {
        for (int i = 0; i <h; ++i) {
            reac[k][i] = 0;
        }
    }

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

    for (int j = 0; j < n; ++j) {
        //各ピンの座標を読み込む
        int nurix = pinx[j];
        int nuriy = piny[j];

        //a = 1
        if (pina[j] == 1) {
            for (int i = 0; i < nurix; ++i) {
                for (int k = 0; k < h; ++k) {
                    reac[i][k] = 1;
                }
            }
        }

        if (pina[j] == 2){
            for (int i = nurix; i < w; ++i) {
                for (int k = 0; k < h; ++k) {
                    reac[i][k] = 1;
                }
            }
        }

        if (pina[j] == 3){
            for (int i = 0; i < w; ++i) {
                for (int k = 0; k < nuriy; ++k) {
                    reac[i][k] = 1;
                }
            }
        }

        if (pina[j] == 4){
            for (int i = 0; i < w; ++i) {
                for (int k = nuriy; k < h; ++k) {
                    reac[i][k] = 1;
                }
            }
        }
    }
    int count =0;
    for (int l = 0; l < w; ++l) {
        for (int i = 0; i < h; ++i) {
            if (reac[l][i] == 0){
                count++;
            }
        }
    }
    cout << count;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  vector<int> num_count(n, 0);

  int max_num = 0;
  bool flag_d0_is_zero = true;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (i == 0 && x != 0) {
      flag_d0_is_zero = false;
    }
    num[i] = x;
    num_count[x]++;
    max_num = max(x, max_num);
  }
  if (num_count[0] != 1 || !flag_d0_is_zero) {
    cout << 0 << endl;
    return 0;
  }

  long long count_num = 1;
  for (int i = 1; i < n; i++) {
    count_num *= num_count[num[i] - 1];
    count_num %= 998244353;
  }
  cout << count_num << endl;
  return 0;
}

Measured memory_bytes: 1024
# coding: utf-8

while True:
	n = int(raw_input())
	if n == 0:
		break
	else:
		char = raw_input()
		for _ in range(n):
			result = ""
			for i in range(len(char)):
#				print("i = {:}".format(i))
				if i == 0:
					c_now = char[0]
					cnt = 1
#					print("** 0 **")
				elif char[i] == c_now:
					cnt += 1
#					print("** 1 **")
				else: #char[i] != c_now
					result += str(cnt) + c_now
#					print(result)
					c_now = char[i]
					cnt = 1
#					print("** 2 **")
			result += str(cnt) + c_now
			char = result
#			print(result)
#			print("###########################")
		print(result)
			

				

Measured memory_bytes: 5488
from collections import OrderedDict

w = input()
count = 0

w2 = list(set(w))
# w2 = list(w2)


num = []
for i in range(len(w2)):
    num.append(w.count(w2[i]))

for i in range(len(w2)):
    if num[i] % 2 == 0:
        count += 1

if(count == len(w2)):
    print('Yes')
else:
    print('No')
 


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

int main(){
  int N, a = 0, x = 0, total = 0;
  cin >> N;
  a = N;
  while(N){
    x = N % 10;
    total += x;
    N /= 10;
  }

  if(a % total == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(void){


int a,b,c;

int i;

int count=0;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++){

if(c%i==0){

count++;

}

}

printf("%d\n",count);

return 0;

}

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

int main(){
    int n,k;
    cin>>n>>k;
    double p[200000] = {0},wa[200000] = {0};
    for(int i=0;i<n;i++){
        double t;
        cin>>t;
        p[i] = (t+1)/2;
        if(i==0){
            wa[i] = p[i];
        }
        else{
            wa[i] = p[i]+ wa[i-1];
        }
        //cout<<wa[i]<<" ";
    }
    //cout<<endl;
    double ans=0;
    if(n==k){
        ans = wa[n-1];
    }
    for(int i=0;i<n-k;i++){
        if(ans < wa[i+k]-wa[i]){
            ans = wa[i+k] -wa[i];
        }
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
#define X first
#define Y second
//#define INF 1e12
 
 
int main() {
	int r;cin>>r;
	double cir = (2.0*M_PI)*r;
	//cout<<2.0*M_PI<<endl;
	cout<<cir<<endl;
	return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<=n;i++)
typedef int long long ll;
using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    a+=b;
    int aa=atoi(a.c_str());
    
   /* for(int i=1;i<=sqrt(aa);i++){
        if(i*i==aa){
            cout<<"Yes"<<endl;
            return 0;
        }
        
    }*/
    
    
    
    if((int)sqrt(aa)==sqrt(aa)){
        cout<<"Yes"<<endl;return 0;
    }
    cout<<"No"<<endl;
   
return 0;
}

Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=e[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){for(var r=e.split("\n"),n=t(r[0].split(" ").map(function(e){return Number(e)}),2),o=n[0],u=n[1],i=r[1].split(" ").map(function(e){return Number(e)}),f=0,l=0;l<o;l++)if(l!=o-1){var a=i[l+1]-i[l];f+=Math.min(a,u)}else f+=u;console.log(f)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 38412
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    AC = [False] * N
    cnt = [0] * N

    for _ in range(M):
        p, s = input().split()
        p = int(p)
        p -= 1
        if s == "AC":
            AC[p] = True
        else:
            if not AC[p]:
                cnt[p] += 1

    ans_a = 0
    ans_p = 0
    for i in range(N):
        if AC[i]:
            ans_a += 1
            ans_p += cnt[i]

    print(ans_a, ans_p)


if __name__ == '__main__':
    main()


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

public class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var vals = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
        var dp = new double[n];
        dp[0] = 0;
        for (int i = 1; i < n; i++)
        {
            dp[i] = Math.Pow(2, 1024);
        }
        for (int i = 1; i < n; i++)
        {
            dp[i] = chmin(dp[i], dp[i - 1] + Math.Abs(vals[i] - vals[i - 1]));
            if (i > 1)
            {
                dp[i] = chmin(dp[i], dp[i - 2] + Math.Abs(vals[i] - vals[i - 2])); 
            }
        }
        Console.WriteLine(dp.Last());
    }

    public static double chmin(double x, double y)
    {
        return x > y ? y : x;
    }
}

Measured memory_bytes: 21344
#include <bits/stdc++.h>
#define double long double
using namespace std;
typedef complex<double> P;
const int INF = 1e9;

double calc_time(P s,P t,P dog,double v){
  dog -= s;
  double a = abs(t*t)-v*v;
  double b = -2*(t.real()*dog.real()+t.imag()*dog.imag());
  double c = abs(dog*dog);

  if(a<0) a*=-1,b*=-1,c*=-1;
  double d = b*b-4*a*c;
  if(d < 0)return -1;
  
  if(-b-sqrt(d)>= 0) return (-b-sqrt(d))/(2*a);
  if(-b+sqrt(d)>= 0) return (-b+sqrt(d))/(2*a);
  return -1;
}

P Go(P s,P t,P dog,double v,double x,double T){
  t*=T;
  dog -= s;
  P res = (t - dog)/abs(t - dog);
  return (res*v*x)+dog+s;
}

int main(){
  
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n&&!m)break;

    P dog[11];
    double v[11];
    for(int i=0;i<n;i++){
      double x,y;
      cin>>x>>y>>v[i];
      dog[i] = P(x,y);
    }

    int ans[11]={};
    while(m--){
      P s,t;
      double x,y;
      cin>>x>>y; s = P(x,y);
      cin>>x>>y; t = P(x,y);

      double mnt = INF ,time[11] = {};
      for(int i=0;i<n;i++){
	time[i] = calc_time(s,t,dog[i],v[i]);
	if(time[i]>=0)mnt = min(mnt,time[i]);
      }
      for(int i=0;i<n;i++){
	if(time[i]>0)dog[i] = Go(s,t,dog[i],v[i],mnt,time[i]);
	ans[i] += time[i] == mnt;
      }


    }

    for(int i=0;i<n;i++){if(i)cout<<" ";cout<<ans[i];}
    cout<<endl;
  }
  return 0;
}

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

int main(){
  int N;
  vector<int> data;

  cin>>N;
  for (int i=0;i<N;i++){
    int d;
    cin>>d;
    data.push_back(d);
  }

  long long int ans = 1;
  long long int num = 2;
  long long int del = 0;
  for (int i=1;i<N;){
    int xi=data[i];
    
    if ((2*num-1)>xi) {
      ans *= (num);
      ans %= 1000000007;
      num --;
      del ++;
    } else {
      i++;
      num ++;
    }
    
  }

  for(int i=N-del;i>1;i--){
      ans *= i;
      ans %= 1000000007;
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(){
	vector<int> s(5);
	for( auto &&i : s ) cin >> i;
	sort(s.rbegin(),s.rend());
	cout << s[0];
	for(int i = 1 ; i < 5 ; i++) cout << " " << s[i];
	cout << endl;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,char>;
using ll=long long;

int main() {
  int N, K;
  cin >> N >> K;
  int a;
  vector<int> V(N, 0);
  for (int i=0; i<N; i++) {
    cin >> a;
    V[a-1]++;
  }
  sort(V.begin(), V.end());
  int s=0;
  for (int i=0; i<N-K; i++) {
    s+=V[i];
  }
  cout << s << endl;
}
 

Measured memory_bytes: 3980
#include <stdio.h>
#include <string.h>
char week[8][4] ={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(void){
  char S[4];
  if(scanf("%s",&S)<1) return 1;
  for(int i=0;i<7;i++){
    if(strcmp(week[i],S)==0)
      printf("%d\n",7-i);
  }
  return 0; 
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
n,K=map(int,input().split())
p=list(map(lambda x:int(x)-1,input().split()))
c=list(map(int,input().split()))
if K == 1:
    print(max(c));exit()
ans = -10**10
def cycle(k):
    mo=k
    clen=0
    cscore=0
    flg = True
    cmax=[-10**10]
    while (mo != k or flg):
        clen+=1
        cscore+=c[mo]
        mo = p[mo]
        cmax.append(max(cmax[-1],cscore))
        if mo == k:
            flg = False
    if cscore<0:
        return cmax[min(K-1,clen-1)]
    return cscore*((K-1)//clen)+cmax[(K-1)%clen+1]
for i in range(n):
    a=cycle(i)
    if a>ans:
        ans = a
print(ans)


Measured memory_bytes: 82796
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

// #define DEBUG 100

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

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7,maxn = 100010;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    int a[5], ans;
    for (int i=0; i<5; i++){
        cin >> a[i];
        if (a[i] == 0) ans = i;
    }

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, q; string s; cin >> n >> q >> s;
    vector<ll> ac(n,0);
    rep(i, n){
        if(i == 0) continue;
        ac[i] = ac[i-1];
        if(s[i] == 'C' && s[i-1] == 'A'){
            ac[i]++;
        }
    }
    //cout << s << endl;
    //for(auto i : ac) cout << i; cout << endl;
    rep(i, q){
        ll a, b; cin >> a >> b;
        cout << ac[b-1] - ac[a-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
n,k=map(int,input().split())
s=input()
a=[]
a.append(0)
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		a.append(i+1)
a.append(n)
if s[-1]=='0':
	m=2*k
else:
	m=2*k+1
t=4*k+1
_max=0
i=len(a)-1
if i- m<0:
	print(n)
else:
	while i-m>=0:
		tmp=a[i]-a[i-m]
		#print('i:{} tmp:{}'.format(i,tmp))
		if tmp>_max:
			_max=tmp
		m=t-m
		i-=1
	if a[i]>_max:
		_max=a[i]
	print(_max)

Measured memory_bytes: 7164
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define FOR(i, k, n) for (int(i) = (k); (i) < (n); ++(i))
#define rep(i, n) FOR(i, 0, n)
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef deque<bool> db;
template <class T>
using vv = vector<vector<T>>;

struct UnionFind
{
  vector<int> par;
  vector<int> sizes;
  int N;

  UnionFind(int n) : par(n), sizes(n, 1)
  {
    for (int i = 0; i < n; i++)
      par[i] = i;
    N = n;
  }

  int find(int x)
  {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if (x == y)
      return;

    if (sizes[x] < sizes[y])
    {
      par[x] = y;
      sizes[y] += sizes[x];
    }
    else
    {
      par[y] = x;
      sizes[x] += sizes[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sizes[find(x)]; }
};

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

  vi p(n);

  rep(i, n)
  {
    cin >> p[i];
    p[i]--;
  }

  UnionFind uf(n);

  rep(i, m)
  {
    int x = 0;
    int y = 0;
    cin >> x >> y;
    uf.unite(--x, --y);
  }

  int count = 0;

  rep(i, n)
  {
    if (uf.same(p[i], i))
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
#define endl '\n'
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
int maxElement(int arr[],int n)
{
    int maxi=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]>maxi)
            maxi=arr[i];
    }
    return maxi;
}
int minElement(int arr[],int n)
{
    int mini=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]<mini)
            mini=arr[i];
    }
    return mini;
}
string trim(const string& str)
{
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}
int main() 
{ 
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    vector<ll> arr(n+1);
    for(int i=1;i<=n;i++) cin>>arr[i];
    ll dp[n+1][n+1];
    for(int i=n;i>=1;i--)
    {
        for(int k=i;k<=n;k++)
        {
            if(i==k)
                dp[i][k]=arr[k];
            else
                dp[i][k]=max(arr[i]-dp[i+1][k],arr[k]-dp[i][k-1]);
        }
    }
    cout<<dp[1][n]<<endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


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

int main() {
  double a,l,x;
  while(cin >> a >> l >> x) {
    double b=sqrt(l*l-(a/2)*(a/2));
    double c=(l+x)/2;
    double d=sqrt(c*c-(l/2)*(l/2));
    printf("%.10f\n",a*b/2+l*d);
  }
  return 0;
}


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

int main(){
	#define int long long
	int H,W,ans;
	cin >> H >> W;
	ans = H*W;
	int h,w;
	for(h=1;h<H;h++){
		int h1,h2,mh,Mh;
		h1 = (H-h)/2;
		h2 = H-h-h1;
		mh = min(min(h,h1),h2);
		Mh = max(max(h,h1),h2);
		if(ans>(Mh-mh)*W)ans = (Mh-mh)*W;//縦幅を三分割
		//cout << ans << " " << Mh*W << " "<< mh*W <<"\n";
		int w1,w2,m,M;
		w1 = W/2;
		w2 = W-w1;
		m = min(h*W,min((H-h)*w1,(H-h)*w2));
		M = max(h*W,max((H-h)*w1,(H-h)*w2));
		if(ans>M-m)ans = M-m;//縦幅を割って横幅を割る
		//cout << ans << " " << M << " "<< m << endl;

	}
	for(w=1;w<W;w++){
		int w1,w2,mw,Mw;
		w1 = (W-w)/2;
		w2 = W-w-w1;
		mw = min(min(w,w1),w2);
		Mw = max(max(w,w1),w2);
		if(ans>(Mw-mw)*H)ans = (Mw*H-mw*H);//縦幅を三分割
		//cout << ans << " " << Mw*H << " "<< mw*H<<"\n";
		int h1,h2,m,M;
		h1 = H/2;
		h2 = H-h1;
		m = min(H*w,min((W-w)*h1,(W-w)*h2));
		M = max(H*w,max((W-w)*h1,(W-w)*h2));
		if(ans>M-m)ans = M-m;//縦幅を割って横幅を割る
		//cout << ans << " " << M << " "<< m << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

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

int cx, cy, dx, dy;

typedef pair<int, int> pii;

#define F first
#define S second

int a[1006][1006];
int b[1006][1006];
queue<pii> bfs(queue<pii> que, int que_id) {
    vector<pii> v;
    while (!que.empty()) {
        pii p = que.front(); que.pop();
        int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
        // move a
        for (int k = 0; k < 4; ++k) {
            int newx = p.F + dx[k], newy = p.S + dy[k];
            if (a[newx][newy] == 0) continue;
            if (b[newx][newy] == -1 || b[newx][newy] == que_id + 1) {
                b[newx][newy] = que_id;
                que.push(make_pair(newx, newy));
            }
        }
        // move b
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                int newx = p.F + i, newy = p.S + j;
                if (a[newx][newy] == 0) continue;
                if (b[newx][newy] == -1) {
                    b[newx][newy] = que_id + 1;
                    v.push_back(make_pair(newx, newy));
                }
            }
        }
    }
    queue<pii> ret;
    for (int i = 0; i < (int)v.size(); ++i) {
        pii p = v[i];
        if (b[p.F][p.S] == que_id + 1) {
            ret.push(p);
        }
    }
    return ret;
}

int main () {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    cin >> cx >> cy >> dx >> dy;
    cx += 1, cy += 1, dx += 1, dy += 1;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        for (int j = 0; j < m; ++j) {
            if (s[j] == '.') {
                a[i + 2][j + 2] = 1;
            }
        }
    }
    memset(b, -1, sizeof(b));
    b[cx][cy] = 0;
    queue<pii> now;
    now.push(make_pair(cx, cy));
    for (int i = 0; ; ++i) {
        now = bfs(now, i);
        if (now.empty()) break;
    }
    cout << b[dx][dy] << endl;
}

Measured memory_bytes: 11776
N,M = (int(i) for i in input().split())

count = [0]*M

for i in range(N):
    k = list(map(int,input().split()))
    k = k[1:]
    for kk in k:
        count[kk-1]+=1
total = 0
for l in count:
    if l ==  N:
        total += 1
print(total)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
  int a,b,c,temp;
  
  scanf("%d %d %d",&a,&b,&c);
  
  temp=a;
  a=b;
  b=temp;
  
  temp=a;
  a=c;
  c=temp;
  
  printf("%d %d %d",a,b,c);
  
  return 0;
}

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

using LL = int64_t;

int main()
{
    LL N; cin >> N;
    vector<int> c(N);
    for (int i = 0; i < N; ++i) {
        cin >> c[i]; --c[i];
    }
    vector<vector<int>> G(N);
    for (int i = 0; i < N-1; ++i) {
        int u, v; cin >> u >> v; --u, --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<vector<LL>> split(N);
    vector<LL> sz(N, 1);
    vector<map<int,LL>> dp(N);

    auto dfs = [&](auto dfs, int v, int p)->void{
        for (int u : G[v]) {
            if (u == p) continue;
            dfs(dfs, u, v);
            sz[v] += sz[u];

            LL ret = sz[u];
            if (dp[u].count(c[v])) ret -= dp[u][c[v]];
            split[c[v]].push_back(ret);

            if (dp[u].size() > dp[v].size()) swap(dp[u], dp[v]);
            for (auto& tp : dp[u]) dp[v][tp.first] += tp.second;
        }

        dp[v][c[v]] = sz[v];
    };

    dfs(dfs, 0, -1);

    for (int i = 0; i < N; ++i) {
        split[i].push_back(N - dp[0][i]);
    }

    vector<LL> ans(N, N*(N+1)/2);
    for (int i = 0; i < N; ++i) {
        for (LL a : split[i]) {
            ans[i] -= a * (a + 1) / 2;
        }
    }

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

    return 0;
}


Measured memory_bytes: 96480
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int ma = 0;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		ma = max(ma, x);
		sum += x;
	}
	if (ma < sum - ma) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
X=input()
L=X[::-1]
N=len(X)
if N % 2 == 1:
    if L==X:
        a=int((N-1)/2)
        b=int((N+3)/2)
        Ya=X[0:a]
        LYa=Ya[::-1]
        Yb=X[b-1:N]
        LYb=Yb[::-1]
        if LYa ==Ya and LYb == Yb:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
const int MAX_N=10010;
vector<ll> c;
vector<int> G[MAX_N];
vector<int> euler_tour;
int Beg[2*MAX_N],End[2*MAX_N]; //begin: 最初に登場するindex, end: 最後に登場するindex+1
int k=0,root=0;
int res=0;
void dfs(int v,int p){
    Beg[v]=k;
    euler_tour.pb(v);
    k++;
    for(int &to: G[v]){
        if(to!=p){
            dfs(to, v);
            euler_tour.pb(v);
            k++;
        }
    }
    End[v]=c[res];
    res++;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    c.resize(N);
    rep(i,0,N-1){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll sum=0;
    rep(i,0,N){
        cin>>c[i];
        sum+=c[i];
    }
    sor(c);
    sum-=c[N-1];
    cout <<sum<<"\n";
    dfs(0,-1);
    rep(i,0,N){
        cout <<End[i]<<" ";
    }
    cout<<"\n";
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long N, std::vector<long long> P)
{
    long long tmp = INF;
    long long ans = 0;
    rep(i, N)
    {
        tmp = min(tmp, P[i]);
        if (tmp == P[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> P(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


Measured memory_bytes: 1792
c=[]
for _ in range(3):
    c.append(list(map(int,input().split())))
a=[0]
b=[]
for i in range(3):
    b.append(c[0][i]-a[0])
for i in range(1,3):
    a.append(c[i][0]-b[0])
for i in range(3):
    for j in range(3):
        if c[i][j]!=a[i]+b[j]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define Y first
#define X second

int H, W, N;
vector<string> ts;

int main(void) {
	cin >> H >> W >> N;
	ts = vector<string>(H);
	for (auto &line : ts) cin >> line;

	string seq(N, '0');
	iota(seq.begin(), seq.end(), '1');
	
	PII start;
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (ts[y][x] == 'S') {
				start.Y = y;
				start.X = x;
			}
		}
	}

	int total_time = 0;
	queue<pair<int, PII>> q;
	q.push(make_pair(0, start));
	vector<vector<bool>> done(H, vector<bool>(W));

	for (int i = 0; i < N; i++) {
		while(q.size()) {
			int now = q.front().first;
			int y = q.front().second.Y;
			int x = q.front().second.X;
			q.pop();

			if (done[y][x]) continue;
			done[y][x] = true;

			if (ts[y][x] == seq[i]) {
				q = queue<pair<int, PII>>();
				q.push(make_pair(0, make_pair(y, x)));
				done = vector<vector<bool>>(H, vector<bool>(W));
				total_time += now;
				break;
			}

			for (int dx = -1; dx <= 1; dx++) {
				for (int dy = -1; dy <= 1; dy++) {
					if (!(!dx ^ !dy)) continue;
					int nx = x + dx;
					int ny = y + dy;

					if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
					if (done[ny][nx]) continue;
					if (ts[ny][nx] == 'X') continue;

					if (!done[ny][nx]) {
						q.push(make_pair(now + 1, make_pair(ny, nx)));
					}
				}
			}
		}
	}

	cout << total_time << endl;
	

	return 0;
}

Measured memory_bytes: 2628
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

x = ni()

print(1 if x==0 else 0)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+7;
typedef long long LL;
int n,sum;
string s;
int quick(int a,int b,int mod){
	LL ans=1;
	while(b){
		if(b&1) ans = ans*a%mod;
		a = (LL)a*a%mod;
		b>>=1;
	}
	return ans;
}
int fun(int n){
	int ans=0;
	while(n){
		ans++;
		n =n &(n-1);
	} 
	return ans;
}
int main(){
	cin>>n>>s;
	for(auto c :s) if(c=='1') sum++;
	int cnt1 = 0 ,cnt2 = 0, p1 = sum + 1 , p2 = sum - 1;
	
	for(int i=0;i<n;i++)
		if(s[i]=='1'){
			cnt1 = (cnt1 + quick(2,n-i-1,p1))%p1;
			if(p2>0) cnt2 = (cnt2 + quick(2,n-i-1,p2))%p2;
		}
	int t,ans=0;
	for(int i=0;i<n;i++){
		ans=1;
		if(s[i]=='0')  t = (cnt1+quick(2,n-i-1,p1)+p1)%p1;
		else if(p2<=0) {cout<<0<<"\n"; continue;}
		else t = (cnt2-quick(2,n-i-1,p2)+p2)%p2;
		if(!t) cout<<ans<<"\n";
		else {
			while(t) ans++,t = t%fun(t);
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3744