akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define LEN 1000005
void enqueue();
void dequeue(void);
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head=1, tail=1, n;
 

int main(){
  int elaps = 0, judgement;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
   
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  tail = i;
   
  while(head < tail){
     
    if(tail == LEN) tail = 1;
    if(head == LEN) head = 1;
    judgement = Q[head].t - q;
     
    if(judgement <= 0){
      elaps += Q[head].t;
      dequeue();
      printf("%s %d\n",Q[head-1].name,elaps);
    }
     
    else{
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);
      dequeue();
    }
  }
  return 0;
}
void enqueue(P x){
   
  Q[tail] = x;
  tail++;
}
 
void dequeue(){
  head++;
}
 

Measured memory_bytes: 21072
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion


vector<ll> divisor(ll num){
    vector<ll> vec;
    for(ll i=1;i*i<=num;i++){
        if(num%i == 0){
            vec.push_back(i);
            if(i*i != num) vec.push_back(num/i);
        }
    }
    sort(begin(vec), end(vec));
    return vec;
}


int main() {
  cin >> N;
  vector<ll> vec = divisor(N-1);
  int count = vec.size() - 1;
  vector<ll> vec2 = divisor(N);
  for(int i=1;i<vec2.size();i++){
    ll curr = N;
    while(curr >= vec2[i]){
      if(curr % vec2[i] == 0) curr /= vec2[i];
      else curr %= vec2[i];
    }
    if(curr == 1) count++;
  }

  cout << count;
} 



Measured memory_bytes: 384
#include <iostream>

using namespace std;
using ll = long long;

const int K = 1e5 + 10;
const int mod = 1e9 + 7;

ll dp[K];

ll qmi(int m, int k, int p) {
    ll res = 1 % p, t = m;
    while (k) {
        if (k & 1) res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}

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

    int n, k;
    cin >> n >> k;

    for (int i = k; i >= 1; --i) {
        dp[i] = qmi(k / i, n, mod);
        for (int j = 2 * i; j <= k; j += i) {
            dp[i] -= dp[j];
            dp[i] = (dp[i] % mod + mod) % mod;
        }
    }

    ll res = 0;
    for (int i = 1; i <= k; i++) (res += dp[i] * i % mod) %= mod;
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 4480
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    int N;
    cin>>N;
    vector<int>a(N);
    rep(i,N){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    int count=0;
    rep(i,N-1){
        if(a.at(i)==a.at(i+1)){
            count++;
        }

    }
    if(count==0){
        cout<<"YES"<<endl;

    }else{
            cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(ll i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<ll, ll> llP;
typedef std::priority_queue<ll> IntPrioQueue; //Z->A
typedef std::priority_queue<ll, std::vector<ll>, std::greater<ll> > IntReversePrioQueue; //A->Z

const ll MAX = 20020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll MOD = 1000000007;

ll ts[MAX], vs[MAX];

ll spd[MAX*2];

void solve(void){
    ll N, sumt = 0;
    cin >> N;
    rep(N, i) {
        scanf("%lld\n", &ts[i]);
        sumt += ts[i];
    }
    rep(N, i) {
        scanf("%lld\n", &vs[i]);
    }
    rep(sumt*2, i) {
        spd[i] = min(i, sumt*2-i);
    }
    ll acct = 0;
    rep(N, i) {
        rep(MAX*2, t) {
            if (t < acct) spd[t] = min(spd[t], 2*vs[i]+acct-t);
            else if (t > acct+ts[i]*2) spd[t] = min(spd[t], 2*vs[i]-ts[i]*2-acct+t);
            else spd[t] = min(spd[t], 2*vs[i]);
        }
        acct += ts[i]*2;
    }
    ll ans = 0;
    rep(sumt*2, t) ans += spd[t];

    printf("%lf\n", ans/4.);
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  vector<int> b;
  for (int i = 0; i < h*w; i++) {
    int a;
    cin >> a;
    b.push_back(a);
  }

  struct operation {
    int x, y, xd, yd;
  };

  vector<operation> op;

  for (int y = 0; y < h; y++) {
    if (y%2 == 0) {
      for (int x = 0; x < w; x++) {
        int i = y*w+x;
        if (b[i]%2 != 0) {
          if (x == w-1) {
            if (y != h-1) {
              //down
              operation newop = {x, y, x, y+1};
              op.push_back(newop);
              b[i+w]++;
            }
          } else {
            //right
            operation newop = {x, y, x+1, y};
            op.push_back(newop);
            b[i+1]++;
          }
        }
      }
    } else {
      for (int x = w-1; x >=0; x--) {
        int i = y*w+x;
        if (b[i]%2 != 0) {
          if (x == 0) {
            if (y != h-1) {
              //down
              operation newop = {x, y, x, y+1};
              op.push_back(newop);
              b[i+w]++;
            }
          } else {
            //left
            operation newop = {x, y, x-1, y};
            op.push_back(newop);
            b[i-1]++;
          }
        }
      }
    }
  }

  cout << op.size() << endl;
  for (operation o : op) {
    cout << o.y+1 << " " << o.x+1 << " " << o.yd+1 << " " << o.xd+1 << endl;
  }

  return 0;
}


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

int main(){

  double a,b,h,m;

  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);

  double H,M;

  M = m*6;
  H = (m + h*60)/2;
  double deg = M - H;
  double pi = acos(-1);
  double rad = deg*(pi/180);

  printf("%.10f\n", sqrt(a*a + b*b - 2*a*b*cos(rad)));

  return 0;
}


Measured memory_bytes: 4228
# スイッチの数、電球の数
N,M = map(int, input().split())
# 電球に紐づいたスイッチの情報を持つリスト
l1 = [0]*M;
for i in range(M):
  l1[i] = list(map(int, input().split()))
# 各電球の点灯条件を持つリスト
l2 = list(map(int,input().split()))
anser = 0
# スイッチのパターンをループでまわす
for i in range(2**N):
  isAll = True
  switch = '{:010b}'.format(i)
  #　各電球が点灯するか判定
  for j in range(M):
    #print('電球'+str(j))
    # スイッチがonになっている個数のカウンター
    count = 0
    # 電球に紐づくスイッチがonになっているかの判定
    for k in range(l1[j][0]):
      # print('スイッチ番号',l1[j][k+1])
      # print('スイッチの状態',switch[9-div:10-div])
      div = l1[j][k+1]-1
      if int(switch[9-div:10-div]) == 1:
        count += 1
    if count%2 != l2[j]:
      isAll = False
      break
  if isAll:
    anser += 1
print(anser)


Measured memory_bytes: 42608
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

count_low = 0
count_high = 0

for i in range(M):
    if A[i] < X:
        count_low += 1
    else:
        count_high += 1

print(min(count_low, count_high))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
  string n;
  cin>>n;
  for(int i=0;i<n.length();i++)
  {
    if(n[i]=='7')
    {
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    int n = N;
    int cnt = 0;
    int k = 1;
    while(n > 0){
        if(n / 10 != 0) k *= 10;
        n /= 10;
        cnt++;
    }
    int ans = 0;
    if(cnt % 2 == 1){
        ans += N - k + 1;
    }
    int t = 1;
    int tem = 10;
    for(int i = 1; i < cnt; i++){
        if(i % 2 == 1){
            ans += tem - t;
        }
        tem *= 10;
        t *= 10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,d=0,e=0;
	cin>>a>>b;
	int c[b+1];
	for(int i=1;i<=b;i++)
	cin>>c[i];
	for(int i=0;i<=b;i++)
	{
		d=0;
		e=0;
		for(int k=1;k<=b;k++)
		{
			if(a+i==c[k])
			{
				d++;
 			}
			if(a-i==c[k])
			{
				e++;
			}
		}
		if(e==0)
		{ 
			cout<<a-i<<endl;
			return 0; 
		} 
		if(d==0)
		{
			cout<<a+i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3640
#include<stdio.h>

int a[110][110];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)scanf("%d",&a[i][j]);
	for(int i=0;i<n;i++){
		int ans=0;
		for(int j=0;j<m;j++)ans+=a[i][j];
		a[i][m]=ans;
	}
	for(int j=0;j<=m;j++){
		int ans=0;
		for(int i=0;i<n;i++)ans+=a[i][j];
		a[n][j]=ans;
	}
	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)printf("%d%c",a[i][j],j==m?'\n':' ');
}


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

int main() {
    long long A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long ans = 10000000000;
    for (long long i=0; i<100010; i++) {
        long long m = i*2*C+max((long long)0, X-i)*A+max((long long)0, Y-i)*B;
        ans = min(ans, m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template< typename T >
size_t LIS(const vector< T > &a, bool strict) {
  vector< T > lis;
  for(auto &p : a) {
    typename vector< T >::iterator it;
    if(strict) it = lower_bound(begin(lis), end(lis), p);
    else it = upper_bound(begin(lis), end(lis), p);
    if(end(lis) == it) lis.emplace_back(p);
    else *it = p;
  }
  return lis.size();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    reverse(a.begin(), a.end());
    cout << LIS(a, false) << endl;
}

Measured memory_bytes: 1276
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, res = 0;
  cin >> n;
  REP(i,n) {
    int a, b;
    cin >> a >> b;
    res += b-a;
  }
  cout << res + n << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {

        var N = Console.ReadLine().ToInt32();
        var A = Console.ReadLine().ToInt32();
        Console.WriteLine(N * N - A);
    }


    
    
    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
}


Measured memory_bytes: 11220
#include <iostream>
#include <stdio.h>
#include <cmath>

using namespace std;


int main(void){
    
    for(int i = 1; i < 10; i++ ){
        for(int j = 1; j < 10; j++ ){
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}


Measured memory_bytes: 3136
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    div = np.zeros(N+1, np.int64)
    for n in range(1, N+1):
      for m in range(n, N+1, n):
        div[m] += 1
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))


Measured memory_bytes: 183252
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
using namespace std;

int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a | b | c) {
		int MAX = 0;
		for (int d = 1; d <= c; d++) {
			for (int e = 1; e <= c; e++) {
				if (d*(100 + a) / 100 + e*(100 + a) / 100 == c) {
					MAX = max(MAX, d*(100 + b) / 100 + e*(100 + b) / 100);
				}
			}
		}
		cout << MAX << endl;
	}
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


const double pi = 3.14159265358979323846;

double torad(double n)
{
    double ans = n*(pi/180);
    return ans;
}

int main(int argv, char* argc[])
{
    FASTIO



    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double hf = (360*h+6*m)/12;
    double angle = abs(hf-(6*m));
    double ans = a*a+b*b - (2*a*b)*cos(torad(angle));
    ans = sqrt(ans);
    cout<<fixed<<setprecision(20)<<ans;


    return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e18;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 1005, MOD = 1e9 + 7;

int dp[N][N];
string grid[N];

int main(){
    fIO

    int h, w;
    cin >> h >> w;

    for(int i = 0; i < h; i++) cin >> grid[i];

    dp[0][0] = 1;

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            dp[i][j] %= MOD;
            if(grid[i][j] == '.') {
                if(grid[i + 1][j] == '.') {
                    dp[i + 1][j] += dp[i][j];
                }
                if(grid[i][j + 1] == '.') {
                    dp[i][j + 1] += dp[i][j];
                }
            }
        }
    }
    cout << dp[h - 1][w - 1];
}











Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll x, ans = 0;
    cin >> x;
    ans += x / 11 * 2;
    x %= 11;
    if(x <= 6 && x != 0)ans++;
    else if (x != 0)ans += 2;
    cout << ans << endl;
}

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

char A[ 100 ];
char B[ 100 ];

int main()
{
int i;
int j;
int N;
set<string> S;

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

	cin >> N;
	cin >> B;

	j = strlen( B );

auto a = S.insert( B );

	for( i = 1; i < N; i++ )
	{
		cin >> A;

		a = S.insert( A );

		if( ! a.second || A[ 0 ] != B[ j - 1 ] )
		{
			cout << "No" << endl;

			return 0;
		}

		strcpy( B, A );
		j = strlen( B );
	}

	cout << "Yes" << endl;

	return 0;
}






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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

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

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans[10000000],a[10000000],b,c,cmp=100000,data,m,h,k,w,x,y,xcmp=0,ycmp=0,sum=0,le,ri;

string s;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i];
       }
       le=100000;
       ri=le+1;
       if(n%2==0){
           rep(i,n){
               if(i%2==1){
                  ans[le]=a[i];
                  le--;
               }
               else{
                  ans[ri]=a[i];
                  ri++;
               }
           }
       }
       else{
            rep(i,n){
               if(i%2==0){
                  ans[le]=a[i];
                  le--;
               }
               else{
                  ans[ri]=a[i];
                  ri++;
               }
           }
       }
       rrep(i,le+1,ri){
           cout << ans[i] << " ";
       }
       cout << endl;
return 0;
}


Measured memory_bytes: 5760
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readString() -> String {
    return readLine()!
}

func readLines(times: Int) -> [String] {
    var array: [String] = []
    for _ in 0..<times {
        array.append(readLine()!)
    }
    return array
}

func readSeparatedStrings() -> [String] {
    return readLine()!.split(separator: " ").map({String($0)})
}

func readSeparatedInts() -> [Int] {
    return readLine()!.split(separator: " ").map({Int($0)!})
}


let nk = readSeparatedInts()
let n = nk[0]
let k = nk[1]

let prices = readSeparatedInts()
let sorted = prices.sorted()

var result = 0
for i in 0..<k {
    result += sorted[i]
}
print(result)


Measured memory_bytes: 13608
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

char s;
LL c1 = 0,c2 = 0;

int main(){
	for(LL i = 1;i <= 3;i ++){
		cin >> s;
		if(s == 'A') c1 ++;
		else c2 ++;
	}
	if(c1 && c2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    ll n; cin >> n;
    cout << 3*n*n;
    return 0;
}


Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let N = get!(i64);
    let p = get!(i64; N);

    let ans = p.iter().fold(0, |sum, x| sum + x) - p.iter().max().unwrap() / 2;

    // 出力
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
int G(int c)
{
	if(strchr("{}",c))return-(c-124)+124;
	if(strchr("[]",c))return-(c-92)+92;
	return!(c-40)+40;
}
char s[256];
int F(char*p,char*q)
{
	if(!(*p&&*q))return 0;
	if(G(*p)==*q)return F(p-1,q+1)+2;
	int x=F(p-1,q),y=F(p,q+1);
	return x>y?x:y;
}
int main()
{
	scanf("%s",s+1);
	char*p=strstr(s+1,"iwi");
	printf("%d\n",F(p-1,p+3)+3);
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  char s[5];
  scanf ("%s", s);
  for (i32 i = 0; i < 3; ++i) {
    if (s[i] == s[i + 1]) {
      puts ("Bad");
      return;
    }
  }
  puts ("Good");
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 128
import sys

def chk(i,j):
    if a[i][j]==".": return 0
    if i>0 and a[i-1][j]=="#" :return 0
    if i<H-1 and a[i+1][j]=="#": return 0
    if j>0 and a[i][j-1]=="#" :return 0
    if j<W-1 and a[i][j+1]=="#": return 0        
    return 1

H,W=map(int,input().split())
a=[input() for i in range(H)]

for i in range(H):
    for j in range(W):
        if chk(i,j): print("No"),sys.exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  int N;

  cin >> N;
  vector<string> str(N);
  for (int i = 0; i < N; i++) {
    cin >> str.at(i);
  }

  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  for (int i = 0; i < N; i++) {
    if (str.at(i) == "AC") {
      AC += 1;
    }
    else if (str.at(i) == "WA") {
      WA += 1;
    }
    else if (str.at(i) == "TLE") {
      TLE += 1;
    }
    else {
      RE += 1;
    }
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}


Measured memory_bytes: 6368
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

void solve() {
    int n; scanf("%d", &n); if (n == 0) exit(0);
    vector<ll> dp(1 << 16);
    for (int i = 0; i < n; i++) {
        int S = 0;
        int m; ll D; scanf("%d %lld", &m, &D);
        for (int i = 0; i < m; i++) {
            int f, t; scanf("%d %d", &f, &t);
            f -= 6; t -= 6;
            for (int j = f; j < t; j++) {
                S |= (1 << j);
            }
        }
        chmax(dp[S], D);
    }
    for (int S = 0; S < (1 << 16); S++) {
        for (int T = S & (S - 1); T > 0; T = (T - 1) & S) {
            chmax(dp[S], dp[T] + dp[S ^ T]);
        }
    }
    printf("%lld\n", dp[(1 << 16) - 1]);
}

int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */

	int kkt = 89;
	while (kkt) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3640
X,K,D = map(int, input().split())
X = abs(X)
if X >= K*D:
    print(X-(K*D))
else:
    K -= X//D
    X = X % D

    if K % 2 == 0:
        print(X)
    else:
        print(abs(X-D)) 
    

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

typedef long long ll;

int main() {        
	ll a, b;
	cin >> a >> b;
	ll ans = 1e18 + 7;
	for (int i = 1; i <= a; ++i) {
		vector<ll> v(3);
		v[0] = i * b ;
		v[1] = ((a - i) / 2) * b;
		v[2] = ((a - i + 1)/2) * b;
		sort(v.begin(),v.end());
		ans = min(ans,v[2] - v[0]);
		v[0] = (i * b);
		v[1] = (b / 2) * (a - i);
		v[2] = ((b + 1) / 2) * (a - i);
		sort(v.begin(),v.end());
		ans = min(ans,v[2] - v[0]);
		//cout << x << " " << y << " " << xx << " " << yy << endl;  
	//	cout << ans << endl;
	}
	//cout << ans << endl;
	for (int i = 1; i <= b; ++i) {
		vector<ll> v(3);
		v[0] = i * a;
		v[1] = ((b - i) / 2) * a;
		v[2] = ((b - i + 1)/2) * a;
		sort(v.begin(),v.end());
		ans = min(ans,v[2] - v[0]);
		v[0] = (i * a);
		v[1] = (a / 2) * (b - i);
		v[2] = ((a + 1) / 2) * (b - i);
		sort(v.begin(),v.end());
		ans = min(ans,v[2] - v[0]);
	}
	cout << ans;
}




Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main()
{
    string s,t;
    int i,c=0;
    cin>>s>>t;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pi pair<int,int>
#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b);i++)
#define repv(vec,v) for(v=(vec).begin(); v!=(vec).end();v++)
#define sz(vec) (int)(vec).size()
#define PB push_back
#define F first()
#define S second()


int main(){
	int a,b,m;
	cin >> a >> b >> m;
	vi va(a), vb(b),vm(m);
	rep(i,0,a-1)
		cin >> va[i];
	rep(i,0,b-1)
		cin >> vb[i];
		
	rep(i,0,m-1){
		int x,y,c;
		cin >> x >> y >> c;
		vm[i] = va[x-1] + vb[y-1] - c;
	}
	auto mm = *min_element(vm.begin(),vm.end());
	auto bb = *min_element(vb.begin(),vb.end());
	auto aa = *min_element(va.begin(),va.end());
	cout << min( mm, bb + aa);
	
	return 0;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys


def solve(S: int, W: int):
    if S <= W:
        print("unsafe")
    else:
        print("safe")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(S, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>
//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	char get,res;
	cin>>get;
	res=get+1;
	cout<<res;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
struct time{
  int h;
  int m;
};
int main(){
  int N,M;
  cin >> N;
  struct time masi[N];
  for(int i=0;i<N;i++)
    cin >> masi[i].h >> masi[i].m;
  cin >> M;
  struct time turu[M];
  for(int i=0;i<M;i++)
    cin >> turu[i].h >> turu[i].m;
  struct time ans[N+M];
  int i = 0;
  int j = 0;
  while(i<N&&j<M){
    if(masi[i].h<turu[j].h){
      ans[i+j].h = masi[i].h;
      ans[i+j].m = masi[i].m;
      i++;
    }
    else if(masi[i].h>turu[j].h){
      ans[i+j].h = turu[j].h;
      ans[i+j].m = turu[j].m;
      j++;
    }
    else if(masi[i].m<turu[j].m){
      ans[i+j].h = masi[i].h;
      ans[i+j].m = masi[i].m;
      i++;
    }
    else if(masi[i].m>turu[j].m){
      ans[i+j].h = turu[j].h;
      ans[i+j].m = turu[j].m;
      j++;
    }
    else{
      ans[i+j].h = masi[i].h;
      ans[i+j].m = masi[i].m;
      i++;
    }
  }
  for(int k=i;k<N;k++){
    ans[j+k].h = masi[k].h;
    ans[j+k].m = masi[k].m;
  }
  for(int k=j;k<M;k++){
    ans[i+k].h = turu[k].h;
    ans[i+k].m = turu[k].m;
  }
  for(int k=0;k<N+M;k++){
    if(k!=0){
      if(ans[k-1].h==ans[k].h&&ans[k-1].m==ans[k].m)
	continue;
      cout << ' ';
    }
    cout << ans[k].h << ":";
    if(ans[k].m<10)
      cout << 0;
    cout << ans[k].m;
  }
  cout << endl;
  return 0;
}

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

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

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

  for (int i = 0; i < n; ++i) {
    s[i] = a[i];
    if (i != 0)
      s[i] += s[i - 1];
  }

  int ans = 1;
  for (int i = n - 2; i >= 0; --i)
    if (a[i + 1] <= s[i] * 2)
      ++ans;
    else
      break;

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<lli,int>, null_type,less<pair<lli,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a){
	f(i,0,a.size())cout<<a[i]<<" ";
	cout<<"\n";
}
v32 Tree[100001];
int height[100001],parent[100001],depth[100001];
void dfs(int u,int p){
    parent[u]=p;
    depth[u]=depth[p]+1;
    for(auto x:Tree[u]){
        if(x==p)continue;
        dfs(x,u);
        height[u]=max(height[u],1+height[x]);
    }
}
int main() { 
    fastio;
    int n;
    cin>>n;
    int u,v;
    cin>>u>>v;
    f(i,0,n-1){
        int u,v;
        cin>>u>>v;
        Tree[u].pb(v);
        Tree[v].pb(u);
    }
    dfs(v,0);
    v32 path;
    path.pb(u);
    while(path.back()!=v){
        path.push_back(parent[path.back()]);
    }
    reverse(path.begin(),path.end());
    int ans=0;
    int pathsize=path.size();
    //DEBUG_ARR(path);
    fd(i,pathsize-1,(pathsize-1)/2){
        int x=path[i];
        ans=max(ans,depth[x]+height[x]);
    }
    ans--;
    cout<<ans-1<<"\n";
    return 0; 	
}

Measured memory_bytes: 12160
using System;

class T1PBCC
{
	static public void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());

		for(long h=1; h<=3500; h++)
		{
			for(long n=1; n<=3500; n++)
			{
				long X = 4*h*n - N*n - N*h;
				long Y = N * h * n;
				if(X > 0 && Y % X == 0)
				{
					Console.WriteLine("{0} {1} {2}", h, n, Y/X);
					return;
				}
			}
		}

	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>


using namespace std;


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> trees(N);
    for (int i = 0; i < N; i++)
        cin >> trees[i];

    sort(trees.begin(), trees.end());

    int min = INT_MAX;
    for (int i = 0; i < N - K + 1; i++) {
        int tmp = abs(trees[i] - trees[i + K - 1]);
        if (min > tmp)
            min = tmp;
    }

    cout << min << endl;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define sti stack<int>
#define stkl stack<ll>
#define qi queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
using namespace std;
int c=0;

void solve(){
	int n=3;
	map<int,int> m;
	while(n--){
		int x;
		cin>>x;
		m[x]++;
	}

	if(m[5]==2&&m[7]==1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}
 
int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
    	c++;
        solve();
    }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 2;
const ll inf = 2e18;
const int sz = 256;
const int max_k = 20;
typedef long long ll;


void input(){
    IOS;
    int n, m;
    cin >> n >> m;
    vector<int>adj[n];
    f(i, m){
        int s, d;
        cin >> s >> d;
        --s; --d;
        adj[s].pb(d);
        adj[d].pb(s);
    }
    vector<bool>visited(n, false);
    function<void(int) > dfs = [&](int u){
        visited[u] = true;
        for(auto & v: adj[u]){
            if(!visited[v])dfs(v);
        }
    };
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(!visited[i]){dfs(i), ++cnt;}
    }
    cout << cnt - 1 << endl;
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

Measured memory_bytes: 10444
#include <stdio.h>

int main(){
	int a[9] = {1,2,3,4,5,6,7,8,9};
	int b[9] = {1,2,3,4,5,6,7,8,9};
	int in;
	int y = 0;
	scanf("%d" ,&in);
	for(int i = 0; i < 9; i++){
		for(int j = 0; j < 9; j++){
			if(a[i] * b[j] == in){
				y++;
			}
		}
	}
	if(y > 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1664
'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(''))
  let cnt = 0
  for (let i = 0; i < 3; i++) {
    if (input[0][i] == input[1][i]) cnt++
  }
  console.log(cnt)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
    int n;
    int h[22];
    int max = 0;
    int ans = 0;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    for (int i = 0; i < n; i++) {
        if (max <= h[i]) {
            max = h[i];
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
main = do
    s <- getLine
    let y = ans s
    print y
    

acgt :: Char -> Bool
acgt x = if x `elem` ['A', 'C', 'G', 'T']
             then True
        else False

acLength :: String -> Int
acLength [] = 0
acLength (x:xs)
    | acgt x = acLength xs + 1
    | otherwise = 0

ans :: String -> Int
ans [] = 0
ans (x:xs) = max (acLength (x:xs)) (ans xs) 


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

int main(){
  string s;
  cin>>s;
  long long int n,i,j,k,x,kotae=0,ima[13],kari[13],keta=0,hugo=1;
  n=s.length();
  for(i=0;i<13;i++){
    ima[i]=0;
    kari[i]=0;
  }
  ima[0]=1;
  for(i=n-1;i>=0;i--){
    if(s[i]!='?'){
      for(j=0;j<13;j++){
        x=((s[i]-'0')*(int)pow(10,keta)*hugo+j)%13;
        if(x<0){
          x+=13;
        }
        kari[x]=ima[j];
      }
    }else{
      for(k=0;k<=9;k++){
        for(j=0;j<13;j++){
          x=(hugo*k*(int)pow(10,keta)+j)%13;
          if(x<0){
            x+=13;
          }
          kari[x]+=ima[j];
        }
      }
    }
    for(j=0;j<13;j++){
      ima[j]=kari[j]%1000000007;
      kari[j]=0;
    }
    if(keta!=2){
      keta++;
    }else{
      keta=0;
      hugo*=-1;
    }
  }
  cout<<ima[5];
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY puts("Yes")
#define NN puts("No")
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int n;
  cin >> n;
  vector<int>v(n),p(n),q(n);
  rep(i,n)cin >> p[i];
  rep(i,n)cin >> q[i];
  rep(i,n)v[i] = i + 1;
  int a,b;
  int count = 1;
  if(v == p && v == q){
    cout << 0 << endl;
    return 0;
  }
  do{
    if(v == p)a = count;
    if(v == q)b = count;
    count++;
  }while(next_permutation(all(v)));
  cout << abs(a - b) << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

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

typedef long long int ll;
typedef vector<ll> vll;

#define all(a) a.begin(), a.end()

template <typename T>
void Reve(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (reverse(n.begin() + a, n.end()));
  }
  else
  {
    return (reverse(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

void fYn(bool a)
{
  if (a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  vll H(n); V(H);
  Reve(H);
  ll miss = 0;
  for(ll i = 1;i < n;i++)
  {
    if(H[i - 1] >= H[i])
    {
    }
    else
    {
      H[i]--;
      if(H[i - 1] >= H[i])
      {
      }
      else
      {
        miss++;
      }
    }
  }
  if(miss == 0) fYn(1);
  fYn(0);
}

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

Measured memory_bytes: 1024
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll h[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int pre = -999;
	for (int i = 0; i < n; i++) {
		if (pre <= h[i] - 1) {
			pre = h[i] - 1;
		}
		else if (pre <= h[i]) {
			pre = h[i];
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

// a^n mod を計算する
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}


int main() {
	int N;
	cin  >> N;
	
	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
	}

	// 最小公倍数を素因数分解の形で保持
	map<int, int> lcm{};
	rep(i, N) {
		int x = A[i];
		for (int j = 2; j*j <= x; j++) { // A[i]の素因数分解
			if (x % j == 0) {
				int cnt = 0; // 指数の添え字
				while (x % j == 0) {
					cnt++;
					x /= j;
				}
				lcm[j] = max(lcm[j], cnt); // 指数の大きいほうが最小公倍数の指数に
			}
		}
		if (x != 1) {
			lcm[x] = max(lcm[x], 1);
		}
	}

	// 最小公倍数を計算
	ll lcmnum = 1;
	for (auto pr : lcm) {
		lcmnum *= modpow(pr.first, pr.second);
		lcmnum %= MOD;
	}

	// 最小公倍数を割ったものを足す
	rep(i, N) {
		ans += lcmnum * modinv(A[i]) % MOD ;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>
int main(void) {
	double w, h;
	int x, y;
	scanf("%lf%lf", &w, &h);
	scanf("%d%d", &x, &y);
 
	printf("%lf ", w * h / 2);
	if (x == w / 2 && y == h / 2)
		printf("1\n");
	else
		printf("0\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int N;
	
	cin >> N;
	
	int ans = 0;
	
	int loop_count = (1 << 15);
	
	for(int loop = 0; loop < N; loop++){
		long long int num;
		cin >> num;
		for(int i = 1; i <= loop_count; i++){
			long long int offset = 3 * i + 1;
			long long int div = 2 * i + 1;
			if(num < offset){
				ans++;
				//cout << num << " ";
				break;
			}
			if((num - offset) % div == 0){
				break;
			}
			if(i == loop_count){
				ans++;
				break;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3132