akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(int argc, char const *argv[])
{
	int x,t;
	scanf("%d%d",&x,&t);
	printf("%d\n", (x <= t) ? 0 : (x - t));
	return 0;
}


Measured memory_bytes: 128
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    s = input()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    char a,b;
    cin >> a >> b;
    if(a == 'H'){
        if(b == 'H')puts("H");
        else puts("D");
    }
    else{
        if(b == 'H')puts("D");
        else puts("H");
    }
}


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

using namespace std;

typedef long long ll;

const int MAXN = 50;
int N, K;
vector<ll> vecx, vecy;
int sum[MAXN][MAXN];

// rectangle (x1, y1), (x2, y2) contains more than K points or not
bool query(ll x1, ll x2, ll y1, ll y2){
  int pnum;
  if(x1 == 0 && y1 == 0) pnum = sum[x2][y2];
  else if(x1 == 0) pnum = sum[x2][y2] - sum[x2][y1-1];
  else if(y1 == 0) pnum = sum[x2][y2] - sum[x1-1][y2];
  else pnum = sum[x2][y2] - sum[x1-1][y2] - sum[x2][y1-1] + sum[x1-1][y1-1];
  if(pnum >= K) return true;
  return false;
}

int main(){
  cin >> N >> K;
  ll x[N], y[N];
  set<pair<ll, ll> > points;
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i];
    vecx.push_back(x[i]);
    vecy.push_back(y[i]);
    points.insert(make_pair(x[i], y[i]));
  }
  sort(vecx.begin(), vecx.end());
  sort(vecy.begin(), vecy.end());
  /*
  for(int i=0;i<N;i++) cout << vecx[i] << " ";
  cout << endl;
  */
  bool isPoint[N][N];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      pair<ll, ll> p = make_pair(vecx[i], vecy[j]);
      if(points.find(p) != points.end()) isPoint[i][j] = true;
      else isPoint[i][j] = false;
    }
  }
  // calculate cumulative sum
  if(isPoint[0][0]) sum[0][0] = 1;
  else sum[0][0] = 0;
  for(int i=1;i<N;i++){
    if(isPoint[0][i]) sum[0][i] = sum[0][i-1] + 1;
    else sum[0][i] = sum[0][i-1];
  }
  for(int i=1;i<N;i++){
    if(isPoint[i][0]) sum[i][0] = sum[i-1][0] + 1;
    else sum[i][0] = sum[i-1][0];
  }

  for(int i=1;i<N;i++){
    for(int j=1;j<N;j++){
      if(isPoint[i][j]) sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + 1;
      else sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    }
  }
  /*
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout << sum[i][j] << " ";
    }
    cout << endl;
  }
  */
  ll minarea = (vecx[N-1] - vecx[0]) * (vecy[N-1] - vecy[0]);
  for(int x1=0;x1<N;x1++){
    for(int x2=x1+1;x2<N;x2++){
      for(int y1=0;y1<N;y1++){
        for(int y2=y1+1;y2<N;y2++){
          if(query(x1, x2, y1, y2)){
            ll area = abs(vecx[x1] - vecx[x2]) * abs(vecy[y1] - vecy[y2]);
            minarea = min(minarea, area);
          }
        }
      }
    }
  }
  cout << minarea << endl;
}

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

using namespace std;

int main(){
	int N;

	cin >> N;
	for (int i = 0; i < N; i++){
		char input;
		cin >> input;

		if(input == 'Y'){
			cout << "Four" << endl;
			goto END;
		}
	}
	cout << "Three" << endl;

END:
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int BASE = 1e9 + 7;

long long power(long long x, long long y)
{
  if (!y)
    return 1;
  long long res = power(x, y >> 1);
  res = res * res % BASE;
  if (y & 1)
    res = res * x % BASE;
  return res;
}

int main()
{
  int h, w, t;
  cin >> h >> w >> t;
  int gh = __gcd(h, t), gw = __gcd(w, t);
  h /= gh;
  w /= gw;

  long long ans = (power(2, h) + power(2, w) - 1 + BASE) % BASE; // empty, only R or only D
  ans = (ans + power(2, __gcd(h, w)) - 2 + BASE) % BASE; // both R and D
  cout << power(ans, 1LL * gh * gw) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int N,K,i,count=0;
   cin>>N;
   cin>>K;
   int a[N];
   for(i=0;i<N;i++)
   {
       cin>>a[i];
       if(a[i]>=K)
       {
           count++;
       }
   }
   cout<<count;


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        int ans[2] = {100000, 100000};
        int a[105];
        int b[105];
        int suma = 0;
        int sumb = 0;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            suma += a[i];
        }
        for(int i = 1; i <= m; i++) {
            cin >> b[i];
            sumb += b[i];
        }
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                if((suma - a[i] + b[j] == sumb - b[j] + a[i])) {
                    if(ans[0] + ans[1] > a[i] + b[j]) {
                        ans[0] = a[i];
                        ans[1] = b[j];
                    }
                }
            }
        }
        if(ans[0] == 100000) cout << -1 << endl;
        else cout << ans[0] << " " << ans[1] << endl;
    }
    return 0;
}


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

using Edge  = pair<ll, ll>;
using Graph = vector<vector<Edge>>;

ll n;
Graph G;

vector<ll> color;

void dfs(ll v, ll p, ll c) {
  color[v] = c;
  for (auto e : G[v]) {
    if (e.first == p) continue;
    if (e.second % 2 == 1) {
      dfs(e.first, v, abs(1 - c));
    } else {
      dfs(e.first, v, c);
    }
  }
}

int main() {
  cin >> n;
  G.assign(n, vector<Edge>());

  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(Edge(v, w));
    G[v].push_back(Edge(u, w));
  }
  color.assign(n, 0);
  dfs(0, -1, 1);

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

Measured memory_bytes: 9984
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    ans = float('inf')
    for i in range(N):
        if A[i] > A[i-1]:
            tmp = (K + A[i-1]) - A[i]
        else:
            tmp = A[i-1] - A[i]
        ans = min(ans, tmp)

    for i in range(N):
        if i == N - 1:
            tmp = A[i] - A[0]
        else:
            tmp = K - (A[i+1] - A[i])
        ans = min(ans, tmp)

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 78728
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  string S;
  cin >> S;
  ll ans = 0;
  for(int l = 1; l <= S.size(); l++){
    for(int r = l; r <= S.size(); r++){
      ll p = max(1, Mypow(2, l-2)) * max(1, Mypow(2, S.size()-r-1));
      ll plus = 0;
      ll d = 1;
      for(int i = r; i >= l; i--){
        plus += (ll)(S[i-1] - '0') * d;
        d *= 10;
      }
      ans += plus * p;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        String s = in.next();
        String t = in.next();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < n; i++) {
            builder.append(s.charAt(i));
            builder.append(t.charAt(i));
        }
        out.println(builder);
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            out.flush();
        } catch (Throwable t) {
            out.flush();
            t.printStackTrace();
        }
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


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

int main(){
  int a,b,n,k,count=0;
  cin >>a>>b>>k;
  if (a>b){
    n=b;
  }
  else {
    n=a;
  }
  
  for (int i=n;i>=1;i--){
    if (a%i==0 && b%i==0){
      count += 1;
    }
    if (count==k){
      cout << i;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 998244353;

ll kai[200001];
ll mokai[200001];

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret*x%MOD;
        x = x*x%MOD;
        y /= 2;
    }
    return ret;
}

void init (int _n) {
    kai[0] = 1;
    for (int i = 1; i <= _n; i++) kai[i] = kai[i-1]*i%MOD;
    for (int i = 0; i <= _n; i++) mokai[i] = mod_pow(kai[i],MOD-2);
}

ll conb (ll x, ll y) {
    ll z = x-y;
    /*
    ll ret = kai[x]*mod_pow(kai[y],MOD-2)%MOD;
    ret = ret*mod_pow(kai[z],MOD-2)%MOD;
    */
    ll ret = kai[x]*mokai[y]%MOD;
    ret = ret*mokai[z]%MOD;
    return ret;
}

int k, n;
ll dp1[2001][2001];
ll dp2[2001][2001];

int main() {
    init(10000);
    cin >> k >> n;
    dp1[0][n] = 1;
    for (int i = 1; i <= k; i++) {
        ll sum = 0;
        for (int j = n; j >= 0; j--) {
            dp1[i][j] = (dp1[i-1][j] + sum*2) % MOD;
            sum = (sum + dp1[i-1][j])%MOD;
        }
    }
    dp2[0][n] = 1;
    dp2[0][n-1] = 1;
    for (int i = 1; i <= k; i++) {
        ll sum = 0;
        for (int j = n; j >= 0; j--) {
            dp2[i][j] = (dp2[i-1][j] + sum*2) % MOD;
            sum = (sum + dp2[i-1][j])%MOD;
        }
    }
    for (int i = 2; i <= 2*k; i++) {
        ll ans = 0;
        ll cnt = 0;
        for (int j = 1; j <= k; j++) {
            int jj = i-j;
            if (j < jj && 1 <= jj && jj <= k) {
                cnt++;
            }
        }
        if (i%2 == 1) {
            if (k-2*cnt-1 < 0) {
                ans = dp1[cnt][0];
            } else {
                for (int j = 0; j <= n; j++) {
                    //cout << dp1[cnt][j] << endl;
                    ans = (ans + dp1[cnt][j] * conb(k-2*cnt-1+j, k-2*cnt-1)) % MOD;
                }
            }
        } else {
            if (k-2*cnt-1-1 < 0) {
                ans = dp2[cnt][0];
            } else {
                for (int j = 0; j <= n; j++) {
                    ans = (ans + dp2[cnt][j] * conb(k-2*cnt-1-1+j, k-2*cnt-1-1)) % MOD;
                }
            }
        }
        cout << ans << endl;
    } 
}



Measured memory_bytes: 65792
#include <iostream>
using namespace std;
int main() {
	int x, y, z, s;
	cin >> s;
	x= s/60/60;
	y= s%(60*60)/60;
	z= s%(60*60)%60;
	cout << x << ":" << y << ":" << z << endl;
	return 0;
}


Measured memory_bytes: 3100
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&a!=c||a==c&&a!=b||b==c&&a!=b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
a,b=gets.split.map(&:to_i)
s = gets.chomp
flag = true
a.times do |i|
    if ![*?0..?9].include?(s[i])
        flag = false
    end
end
if s[a] != ?-
    flag = false
end
b.times do |i|
    if ![*?0..?9].include?(s[a + i + 1])
        flag = false
    end    
end
puts flag ? "Yes" : "No"

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

int main() {
  int n;
  cin >> n;
  //cout << n << endl;
  
  vector <int> S(n);
  for (int i = 0; i < n; i++) {
    cin >> S.at(i);
    //cout << S.at(i) << endl;
  }
  sort(S.begin(), S.end());
  cout << S.at(n/2) - S.at(n/2-1) << endl;
  /*
  for (int i = 0; i < S.size(); i++) {
    cout << S.at(i) << endl;
  }
  */
  /*if (S.at(n/2) == S.at(n/2-1)) {
    cout << 0 << end;
  }
  if (S.at(n/2) != S.at(n/2-1)) {
    cout << S.at(n/2) - S.at(n/2-1) << endl;
  }*/
}

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 998244353

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

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x,y;
    cin >>x>>y;

    if(x == 1 && y==1){
        ans += 400000;
    }

    ans += 300000 - 100000*min(x-1,3);
    ans += 300000 - 100000*min(y-1,3);

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	
	string s;
	while(cin >> s)
	{
		int wade[27] = {0};
		int len = s.size();
		for(int i=0;i<len;i++)
		{
			if(s[i] == 'a')
				wade[0]++;
			if(s[i] == 'b')
				wade[1]++;
			if(s[i] == 'c')
				wade[2]++;
			if(s[i] == 'd')
				wade[3]++;
			if(s[i] == 'e')
				wade[4]++;
			if(s[i] == 'f')
				wade[5]++;
			if(s[i] == 'g')
				wade[6]++;
			if(s[i] == 'h')
				wade[7]++;
			if(s[i] == 'i')
				wade[8]++;
			if(s[i] == 'j')
				wade[9]++;
			if(s[i] == 'k')
				wade[10]++;
			if(s[i] == 'l')
				wade[11]++;
			if(s[i] == 'm')
				wade[12]++;
			if(s[i] == 'n')
				wade[13]++;
			if(s[i] == 'o')
				wade[14]++;
			if(s[i] == 'p')
				wade[15]++;
			if(s[i] == 'q')
				wade[16]++;
			if(s[i] == 'r')
				wade[17]++;
			if(s[i] == 's')
				wade[18]++;
			if(s[i] == 't')
				wade[19]++;
			if(s[i] == 'u')
				wade[20]++;
			if(s[i] == 'v')
				wade[21]++;
			if(s[i] == 'w')
				wade[22]++;
			if(s[i] == 'x')
				wade[23]++;
			if(s[i] == 'y')
				wade[24]++;
			if(s[i] == 'z')
				wade[25]++;
		}
		int flag = 1;
		for(int i=0;i<26;i++)
		{
			if(wade[i] > 1)
			{
				flag = 0;
				break;				
			}	
		} 
		if(flag == 0)
			cout << "no" << endl;
		if(flag == 1)
			cout << "yes" << endl;
	}	
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int JOI[1024][1024][3];
char m[1024][1024];
int main()
{
	int W,H,K,x,y,k,a,b,c,d;
	scanf("%d%d%d",&H,&W,&K);
	for(y=0;y<H;++y)scanf("%s",m[y]);
	for(y=0;y<H;++y)for(x=0;x<W;++x)
	{
		for(k=0;k<3;++k)
			JOI[y+1][x+1][k]=JOI[y+1][x][k]+JOI[y][x+1][k]-JOI[y][x][k];
		JOI[y+1][x+1][c=m[y][x],c=='J'?0:c=='O'?1:2]++;
	}
	while(K--)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
#define P(k) JOI[c][d][k]+JOI[a-1][b-1][k]-JOI[a-1][d][k]-JOI[c][b-1][k]
		printf("%d %d %d\n",P(0),P(1),P(2));
	}
	return 0;
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
char s[105][105];
int a[105],b[105];
int n,m;//行与列 
int t,d,k;//标记
int i,j;//循环变量 
int main(){
//	freopen("in.txt","r",stdin);
    cin>>n>>m;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>s[i][j];
		}
	}
	for(i=1;i<=n;i++){
		t=0;
		for(j=1;j<=m;j++){
			if(s[i][j]=='.'){
				t++;
			}
		}
		if(t==m){
		    a[i]=1;//如果‘.’个数等于行的格数，就代表这一行都是‘.’ 
	    }//判断行完毕 
	
	}

	//------------------------------------------------------------
	//开始判断列
	for(i=1;i<=m;i++) {
		d=0; 
		for(j=1;j<=n;j++){
			if(s[j][i]=='.'){
				d++;
			}
		}
		if(d==n){
		    b[i]=1;
        }
	}

	//----------------------------------------------
	//开始删除
	 for(i=1;i<=n;i++){
	 	k=0;
	 	for(j=1;j<=m;j++){
	 		if(a[i]||b[j]){
	 			continue;//有一行满足，越过不打印（相当于删除） 
			 }
			 k=1;
			 cout<<s[i][j];//输出跃过后的队列 
		 }
		 if(k==1){//删去间隔 
	 	     cout<<endl; 
	     } 
	 }
	 return 0;  
}

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

int a[6];

int main()
{
  cin >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
  for(int i = 1; i <= 5; ++i)
    if(a[i] == 0)
    {
      cout << i;
      break;
    }
}

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


void solve(long long a, long long b){
    cout << ((a * b % 2 == 0) ? "Even" : "Odd") << endl;
}

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


Measured memory_bytes: 256
/*  Author:  Hariom_Pandey
    Created: 1/10/2020 5:38:03 PM
*/
#include "bits/stdc++.h"
using namespace std;
#define Hariom_Pandey  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main(){

    Hariom_Pandey
    int a=500,b,c;
    cin>>b>>c;
    if(b*a>=c) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    

    
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

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

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

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

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

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class AABProblem {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, a, b;
        in >> n >> a >> b;
        ll res;
        if (a > b) {
            res = 0;
        } else if (n == 1) {
            res = a == b;
        } else {
            ll mini = (ll) (n - 1) * a + b, maxi = (ll) (n - 1) * b + a;
            res = maxi - mini + 1;
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    AABProblem solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n;
  cin >> n;
  vi32 p(n), plus(n);
  cin >> p;
  rep(i, n) plus[--p[i]] = i + 1;
  vi32 a(n), b(n);
  rep(i, n) a[i] = 1 + 30000 * i;
  rep(i, n) b[i] = 30000 * (n - i - 1) + plus[i];
  cout << a << '\n';
  cout << b << '\n';
  // vi32 c(n);
  // rep(i, n) c[i] = a[p[i]] + b[p[i]];
  // cerr << c << '\n';
}


Measured memory_bytes: 896
def main():
    s = aread("str")
    print(s[0][0] + s[1][0] + s[2][0])

def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input().split( ))
    return ret


def scan():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, a;cin >> n >> a;
    string ans = "No";
    if(n%500 <= a) ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map( int, input().split() )
edge_list = []
for _ in range( m ):
    a_i, b_i, c_i = map( int, input().split() )
    edge_list.append( ( a_i - 1, b_i - 1, - c_i ) )

INF = float("inf")
cost = [ INF ] * n
cost[ 0 ] = 0

NegativeLoopExist = False
for i in range( n ):
    for j in range( m ):
        a, b, c = edge_list[ j ]
        if cost[ a ] != INF and cost[ b ] > cost[ a ] + c:
            cost[ b ] = cost[ a ] + c
            if i == n - 1 and b == n - 1:
                NegativeLoopExist = True

if NegativeLoopExist:
    print( "inf" )
else:
    print( - cost[ n - 1 ] )

Measured memory_bytes: 3316
// https://atcoder.jp/contests/abc127/tasks/abc127_c

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, l, r, ansmin = 0, ansmax = INF;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> l >> r;
        ansmin = max(ansmin, l);
        ansmax = min(ansmax, r);
    }
    cout << max(0LL, ansmax - ansmin + 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define getfiles ifstream cin("input.txt");ofstream cout("output.txt");
#define closefiles cin.close();cout.close();
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
using namespace std;

int main()
{
    ll n;
    cin>>n;
    vector<vector<ll>>dp(n,vector<ll>(3));
    vector<vector<ll>>a(n,vector<ll>(3));
    for(ll i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(ll i=1;i<n;i++){
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 11136
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 305
#define int long long

using namespace std;

int n;
int dis[MAX_N][MAX_N];

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%lld",&dis[i][j]);
		}
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(i!=j && j!=k && i!=k)
				{
					if(dis[i][j]>dis[i][k]+dis[k][j])
					{
						printf("-1\n");
						return 0;
					}
				}
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			bool flag=true;
			for(int k=1;k<=n;k++)
			{
				if(i!=j && j!=k && i!=k)
				{
					if(dis[i][j]==dis[i][k]+dis[k][j])
					{
						flag=false;
						break;
					}
				}
			}
			if(flag) ans+=dis[i][j];
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MOD = 998244353;

int main(){
    long long N;
    string S;
    while(cin >> N >> S){
        vector<long long> dig(N+1, 0);
        for(int i=0;i<N;i++) dig[i+1] = (2*dig[i]+S[i]-'0')%MOD;
        vector<long long> key;
        vector<long long> num;
        long long res = 0;
        for(int div=(N-1)/2*2+1;div>=1;div-=2){
            if(N%div) continue;
            const long long d = N/div;
            long long cur = dig[d];
            bool ok = true;
            for(int i=0;i<N;i++){
                int cmp = S[i%d] - '0';
                if(i/d%2) cmp = 1 - cmp;
                if(S[i] - '0' < cmp) ok = false;
                else if(S[i] - '0' > cmp) break;
            }
            if(ok) cur = (cur+1) % MOD;
            for(int i=0;i<key.size();i++){
                if(d%key[i] == 0) cur = (cur + MOD - num[i]) % MOD;
            }
            key.push_back(d);
            num.push_back(cur);
            res = (res + 2 * d * cur) % MOD;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 2180
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const {
    for(int i=0;i<N2;i++) {
      if(f[i] == p.f[i]) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle);
string bfs(Puzzle);

bool isTarget(Puzzle p) {
  for(int i=0;i<N2;i++) 
    if(p.f[i] != (i+1) ) return false;
    return true;
}

int main() {

  Puzzle in;
  for(int i=0;i<N2;i++) {
    cin >> in.f[i];
    if(in.f[i] == 0) {
      in.f[i] = N2;
      in.space = i;
    }
  }

  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}    

string bfs(Puzzle s) {

  queue<Puzzle> Q;
  map<Puzzle,bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while( !Q.empty() ) {
    u = Q.front(); Q.pop();
    if(isTarget(u) ) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int r=0;r<4;r++) {
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if(tx<0 || ty<0 || tx >=N || ty >= N ) continue;
      v = u;
      swap(v.f[u.space],v.f[tx*N+ty]);
      v.space = tx*N+ty;
      if( !V[v] ) {
	V[v] = true;
	v.path += dir[r];
	Q.push(v);
      }
    }
  }

  return "unsolvable";
}

     



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

const int N = 2e5 + 5, inf = 0x3f3f3f3f;

int n, k, c, l[N], r[N];
char s[N];

int main() {
    cin >> n >> k >> c >> (s + 1);
    for (int i = 1, last = -inf, tot = 0; i <= n; ++i) {
        if (s[i] == 'x') l[i] = tot;
        else {
            if (i - last - 1 >= c) l[i] = ++tot, last = i;
            else l[i] = tot;
        }
    //    cout << i << " " << s[i] << " " << l[i] << endl;
    }
    for (int i = n, last = inf, tot = 0; i; --i) {
        if (s[i] == 'x') r[i] = tot;
        else {
            if (last - i - 1 >= c) r[i] = ++tot, last = i;
            else r[i] = tot;
        }
    }
   // for (int i = 1; i <= n; ++i) cout << l[i] << endl;
    for (int i = 1; i <= n; ++i) if (s[i] == 'o') if (l[i - 1] + r[i + 1] < k) cout << i << endl;
    return 0;
}

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

using namespace std;

const int N = 2010;
const int mod = 924844033;

int dp[N][N][2];
int fact[N];
int res[N], new_res[N];
int cur[N];
int can_up[N], can_down[N];

int add(int a, int b) {
  int ret = a + b;
  if (ret >= mod) {
    ret -= mod;
  }
  return ret;
}

int sub(int a, int b) {
  int ret = a - b;
  if (ret < 0) {
    ret += mod;
  }
  return ret;
}

int mul(int a, int b) {
  return (long long) a * b % mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  fact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = mul(i, fact[i - 1]);
  }
  int total = 0;
  res[0] = 1;
  for (int start = 0; start < 2 * k; start++) {
    int m = 0;
    for (int i = start; i < n; i += 2 * k) { 
      can_up[m] = i - k >= 0;
      can_down[m] = i + k < n;
      m++;
    }
    for (int i = 0; i <= m; i++) {
      for (int j = 0; j <= m; j++) {
        for (int t = 0; t < 2; t++) {
          dp[i][j][t] = 0;
        }
      }
    }
    dp[0][0][0] = 1;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j <= i; j++) {
        for (int t = 0; t < 2; t++) {
          if (dp[i][j][t] == 0) {
            continue;
          }
          dp[i + 1][j][0] = add(dp[i + 1][j][0], dp[i][j][t]);
          if (can_up[i] && t == 0) {
            dp[i + 1][j + 1][0] = add(dp[i + 1][j + 1][0], dp[i][j][t]);
          }
          if (can_down[i]) {
            dp[i + 1][j + 1][1] = add(dp[i + 1][j + 1][1], dp[i][j][t]);
          }
        } 
      }  
    }
    for (int j = 0; j <= m; j++) {
      cur[j] = add(dp[m][j][0], dp[m][j][1]);
    }
    for (int j = 0; j <= total + m; j++) {
      new_res[j] = 0;
    }
    for (int i = 0; i <= total; i++) {
      for (int j = 0; j <= m; j++) {
        new_res[i + j] = add(new_res[i + j], mul(res[i], cur[j]));
      }
    }    
    total += m;
    for (int j = 0; j <= total; j++) {
      res[j] = new_res[j];
    }
  }
  int ans = 0;
  for (int i = 0; i <= total; i++) {
    if (i % 2 == 0) {
      ans = add(ans, mul(fact[n - i], res[i]));
    } else {
      ans = sub(ans, mul(fact[n - i],  res[i]));
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 16128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

int f(int a,int b){
  if(a%b==0) return (a/b)*2*b-b; 
  return (a/b)*2*b+f(b,a%b);
}

signed main(void) {
  int i,j;
  int n,x;
  cin>>n>>x;
  cout<<n+f(n-x,x)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int n;
	cin >> n;
	vector<int> vec(n);
	// int maxi = 0;
	for(int i = 0; i < n; i++){
		cin >> vec[i];
		// maxi = max(maxi, vec[i]);
	}
	map<int,int> count;
	for(int i = 0; i < n; i++)
		count[vec[i]]++;
	long long maxi = 2 * 1e5 + 1; 
	vector<long long> combi(maxi + 1);
	for(long long i = 1; i <= maxi; i++)
	{
		combi[i] = i * (i-1)/2;
	}
	long long ans = 0;
	for(auto it = count.begin(); it != count.end(); it++)
	{
		ans += combi[it->second];
	}
	// cout << maxi << " " << ans << endl;
	for(int i = 0; i < n; i++)
	{
		long long res = ans;
		if(count[vec[i]] > 1)
		{
			res -= combi[count[vec[i]]];
			res += combi[count[vec[i]] - 1];
		}
		cout << res << endl;

	}

	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	string s,t;
	cin >> s>>t;
	int count = 0;

	rep(i,s.length()){
		if(s[i] != t[i] ) count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3832
lim = 200001
n, m, k = map(int, input().split())
modi = 998244353

fa = [1] * (lim + 1)
fa_inv = [1] * (lim + 1)

for i in range(lim):
    fa[i+1] = fa[i] * (i+1) % modi

fa_inv[-1] = pow(fa[-1], modi - 2, modi)
for i in range(lim - 1, 0, -1):
    fa_inv[i] = fa_inv[i+1] * (i+1) % modi


def ncr(a, b):
    if a < b:
        return 0
    else:
        return fa[a] * fa_inv[b] % modi * fa_inv[a - b] % modi


prt = [1] * (n + 1)
for i in range(n):
    prt[i+1] = prt[i] * (m - 1) % modi

res = 0
for i in range(k + 1):
    res += m * prt[n - i - 1] * ncr(n - 1, i) % modi
    res %= modi
print(res)


Measured memory_bytes: 75532
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int[] ta = {-1,0,1,-1,0,1,-1,0,1};
	static int[] tb = {1,1,1,0,0,0,-1,-1,-1};

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long h = in.nextLong();
			long w = in.nextLong();
			int n = in.nextInt();

			Map<Long, Integer> map = new HashMap<>();
			for (int i = 0; i < n; i++) {

				int a = in.nextInt();
				int b = in.nextInt();

				for (int j = 0; j < 9; j++) {
					int ma = a + ta[j];
					int mb = b + tb[j];
					if (2 <= ma && ma <= h-1 && 2 <= mb && mb <= w-1) {
						long hash = hash(ma, mb);
						int v = map.containsKey(hash) ? map.get(hash) : 0;
						map.put(hash, v+1);
					}
				}
			}

			long[] count = new long[10];
			for (int v : map.values()) {
				count[v]++;
			}

			count[0] = (h-2)*(w-2)-map.size();

			for (int i = 0; i < count.length; i++) {
				out.println(count[i]);
			}

		}
		static long hash(int ma, int mb) {
			return (long)ma<<32|mb;
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

using namespace std;

int main()
{
    string buffer;
    cin >> buffer;

    if (buffer == "SSS")     { cout << 0 << endl;}
    else if (buffer == "RSS") { cout << 1 << endl; }
    else if (buffer == "SRS") { cout << 1 << endl; }
    else if (buffer == "SSR") { cout << 1 << endl; }
    else if (buffer == "RRS") { cout << 2 << endl; }
    else if (buffer == "SRR") { cout << 2 << endl; }
    else if (buffer == "RSR") { cout << 1 << endl; }
    else if (buffer == "RRR") { cout << 3 << endl; }

    return 0;
}


Measured memory_bytes: 3588
from collections import defaultdict
from math import gcd
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7

def normalize(A, B):
    if A < 0:
        A = -A
        B = -B
    elif A == 0:
        B = abs(B)
    g = gcd(A, B)
    A //= g
    B //= g
    return (A, B)

N = int(input())

d = defaultdict(int)

for _ in range(N):
    A, B = map(int, input().split())
    if A == 0 and B == 0:
        d[(0, 0)] += 1
    else:
        A, B = normalize(A, B)
        d[(A, B)] += 1

if len(d) == 1:
    print(N) 
else:
    ans_without_0 = 1
    seen = []
    for k, v in d.items():
        if k != (0, 0) and k not in seen:
            k_2 = normalize(k[1], -k[0])
            if k_2 in d:
                seen.append(k_2)
                ans_without_0 *= (pow(2, v, MOD) + pow(2, d[k_2], MOD) - 1)
            else:
                ans_without_0 *= pow(2, v, MOD)
            ans_without_0 %= MOD
    print((ans_without_0 + d[(0, 0)] - 1) % MOD)


Measured memory_bytes: 112628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[100005];
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    int hmin=1000000000;
    for(int i=1;i<=n-k+1;i++)
    {
        hmin=min(hmin,a[i+k-1]-a[i]);
        if(hmin==0)break;
    }
    printf("%d\n",hmin);
    return 0;
}


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

const int MAX_N = 15;
int dist[MAX_N][MAX_N];  // dist[i][j] i から j への距離

// dp[i][j]: 状態iでjにいるときの最短経路
// 状態iはビットで管理: 00011->点0と点1は通貨済
int dp[1 << MAX_N][MAX_N];
int n, m;
const int inf = 1001001;

// 巡回セールスマン問題
int dfs(int s, int v) {
  if (dp[s][v] >= 0) return dp[s][v];
  if (s == (1 << n) - 1 && v == 0) return dp[s][v] = 0;

  int ans = inf;
  rep(u, n) {
    // uに行ったことがない場合
    if (!(s >> u & 1)) ans = min(ans, dfs(s | 1 << u, u) + dist[v][u]);
  }

  return dp[s][v] = ans;
}

int main() {
  cin >> n >> m;
  memset(dp, -1, sizeof(dp));
  // パスがない場合は距離がinfになる
  fill(dist[0], dist[0] + MAX_N * MAX_N, inf);

  rep(i, m) {
    int f, t, c;
    cin >> f >> t >> c;
    dist[f][t] = c;
  }
  int ans = dfs(0, 0);
  ans = ans == inf ? -1 : ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5020
S=input()
T=input()
L,M=len(S),len(T)
a=-1
for i in range(L-M,-1,-1):
    if sum([1 for j in range(M) if S[i+j]=='?' or S[i+j]==T[j]])==M:
        a=i
        break
print('UNRESTORABLE' if a<0 else ''.join([T[i-a] if a<=i<a+M else 'a' if S[i]=='?' else S[i] for i in range(L)]))

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

int main(){
  unsigned long long int n;
  cin >> n;
  
  vector<unsigned long long int> vec(n);
  for(int i = 0;i < n;i ++){
    cin >> vec.at(i);
  }
  
  unsigned long long int count = 0;
  for(unsigned long long int i = 0;i < n;i ++){
    if(i != 0){
      if(vec.at(i) < vec.at(i - 1)){
        count += (vec.at(i - 1) - vec.at(i));
        vec.at(i) = vec.at(i - 1);
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 4816
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>

#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, weight;

	bool operator < (const Edge& obj) const {
		return weight < obj.weight;
	}
	bool operator > (const Edge& obj) const {
		return weight > obj.weight;
	}
};

int mod_pow(ll x, int n, int mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x*x%mod;
		n >>= 1;
	}
	return res;
}

int divmod(int a,int b, int m) { // a/b(mod m)
	// a/b (mod m)
	// a*b^-1
	// b^-1 * b = 1
	// b^(m-1) = 1 
	// b^(m-2) * b = 1
	// b^-1 = b^(m-2)

	// a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b,m-2, m)) % m;
}

int comb(int n, int r, int mod) {

	int ret = 1,bo = 1;
	REP(i, r) {
		(ret *= n - i)%=MODU;
		(bo *= r-i)%=MODU;
	}

	return divmod(ret, bo, mod);

}

int main()
{
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
	return 0;
}


Measured memory_bytes: 504