akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::str;
use std::usize;
use std::cmp;

fn mod_pow(x: i64, mut exp: i64, modulo: i64) -> i64 {
    let mut result = 1;
    let mut cur = x;
    while exp > 0 {
        if exp & 1 == 1 {
            result = (result * cur) % modulo;
        }
        cur = (cur * cur) % modulo;
        exp >>= 1;
    }
    result
}

fn main() {
    let modulo = 998244353;
    let n = read_values::<usize>()[0];
    let (x, y) = {
        let mut x = vec![0; n];
        let mut y = vec![0; n];
        for i in 0..n {
            let v = read_values::<i32>();
            x[i] = v[0];
            y[i] = v[1];
        }
        (x, y)
    };

    let mut ans = mod_pow(2, n as i64, modulo) - (n as i64) - 1;
    for i in 0..n {
        for j in (i + 1)..n {
            let dx = x[j] - x[i];
            let dy = y[j] - y[i];

            let mut count = 0;
            let mut min = n;
            let mut max = 0;
            for t in 0..n {
                let tx = x[t] - x[i];
                let ty = y[t] - y[i];
                if (tx * dy - ty * dx).abs() != 0 {
                    continue;
                }

                min = cmp::min(min, t);
                max = cmp::max(max, t);
                count += 1;
            }

            if min != i || max != j {
                continue;
            }

            ans = (ans - (mod_pow(2, count, modulo) - count - 1) + modulo) % modulo;
        }
    }

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

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T>
    where T: std::str::FromStr,
          T::Err: std::fmt::Debug
{
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int counter = 1;
            for (; ; )
            {
                var inputLine = Console.In.ReadLine();
                var integer = int.Parse(inputLine);
                if (integer == 0)
                {
                    break;
                }

                Console.WriteLine("Case {0}: {1}", counter, integer);
                ++counter;
            }
        }
    }
}


Measured memory_bytes: 17904
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  string s,t,u;
  c2(s,t);
  int str;
  str=max(s.size(),t.size());
  int a[str]={}, b[str]={};
  int c;
  rep(i,0,s.size()){
    c=s[i];
    a[i]=c;
  }
  rep(i,0,t.size()){
    c=t[i];
    b[i]=c;
  }
  sort(a, a+s.size());
  sort(b, b+t.size()); reverse(b, b+t.size());
  int z=0;
  rep(i,0,str){
    if(a[i]<b[i]){
      u="Yes";
      break;
    }
    else if(a[i]>b[i]){
      u="No";
      break;
    }
    else z++;
  }
  if(z==str) co("No");
  else co(u);
  
  return 0;
}


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



using namespace std;

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


long long int n,m,k;
long long int x,y;
long long int mod = 1000000007;

long long int factorial(long long int n){
    long long int res;
    if (n == 0) return 1;
    res = (n%mod)*factorial(n-1)%mod;
    return res;
}

long long int f(long long int n, long long int m){
    long long int res;
    if(m == 1){
        return n;
    }
    if(m%2){
        res = n*f(n*n%mod, m/2)%mod;
    }
    else{
        res = f(n*n%mod, m/2)%mod;
    }
    return res;
}

int main(){
    cin >> x >> y;
    if((x+y) % 3 != 0 || 2*x-y < 0 || 2*y - x < 0) {
        cout << 0 << endl;
        return 0;
    }
    n = (2*x - y)/3;
    m = (2*y - x)/3;

    long long int nf, mf, nmf, nr, mr;
    nf = factorial(n);
    // cout << n << " " << nf << endl;
    mf = factorial(m);
    nmf = factorial(n+m);
    nr = f(nf,mod-2);
    mr = f(mf,mod-2);
    long long int ans;
    ans = (nr%mod)*(mr%mod);
    ans = (ans%mod)*(nmf%mod)%mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 24300
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
int ans[1005][1005];
signed main() {
	int h, w, a, b; cin >> h >> w >> a >> b;
	rep(i, b)rep(j, a)ans[i][j]++;
	for (int i = b; i < h; i++)for (int j = a; j < w; j++)ans[i][j]++;
	rep(i, h){rep(j, w)cout << ans[i][j]; cout << endl;
}
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b;cin>>a>>b;
    cout << a+b/2 << ednl;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<long double, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << #i <<" "<<i<< std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;
 
void replace_all(std::string& s,std::string target,std::string replace){
  if(!target.empty()){
    long long now=0;
    while((now=s.find(target,now))!=std::string::npos){
      s.replace(now,target.length(),replace);
      now+=replace.length();
    }
  }
}
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  std::string s;
  std::cin>>s;

  replace_all(s,"BC","D");

  ll n=s.size();

  ll ans=0;
  ll a=0,d=0;

  s+='B';

  rep(i,0,n+1){
    if(s[i]=='B'||s[i]=='C'){
      a=0;
      d=0;
    }else if(s[i]=='A'){
      a++;
    }else{
      ans+=a;
      d++;
    }
  }

  std::cout<<ans;

  return 0;
}





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

int main(int argc, char const *argv[])
{
    int A, B;
    cin >> A >> B;

    if (A == B)
    {
        cout << A + B << endl;
    }
    else if (A - 1 >= B)
    {
        cout << A * 2 - 1 << endl;
    }
    else
    {
        cout << B * 2 - 1 << endl;
    }

    return 0;
}

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

using namespace std;

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 9;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e9) return 10;
  if (x >= (long long)1e8) return 9;
  if (x >= (long long)1e7) return 8;
  if (x >= (long long)1e6) return 7;
  if (x >= (long long)1e5) return 6;
  if (x >= (long long)1e4) return 5;
  if (x >= (long long)1e3) return 4;
  if (x >= (long long)1e2) return 3;
  if (x >= (long long)1e1) return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  char c;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char* s) {
  for (int i = 0; s[i] != 0; ++i) print(s[i]);
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int ct = 0;
  char t;
  for (int i = 0; i < N; ++i) {
    char l, r;
    scan(l);
    scan(t);
    scan(r);
    scan(t);
    if (l == r) {
      ct++;
      if (ct >= 3) {
        println("Yes");
        return 0;
      }
    } else {
      ct = 0;
    }
  }
  println("No");
  return 0;
}

Measured memory_bytes: 3632
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> P;
	std::cin >> N;
	P.resize(N);
	for (auto& p : P)
		std::cin >> p;

	int result = 1;
	int minval = P[0];
	for (int i = 1; i < N; ++i) {
		if (P[i] < minval) {
			++result;
			minval = P[i];
		}
	}
	std::cout << result << "\n";
}


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

using namespace std;

typedef long long ll;

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

	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	
	sort(a.begin(), a.end(), greater<int>());

	int x = a[0] - a[1];
	int y = a[0] - a[2];

	int ans = x / 2 + y / 2;
	if(x % 2 == 0 && y % 2 == 0){
	}else if(x % 2 == 0){
		ans += 2;
	}else if(y % 2 == 0){
		ans += 2;
	}else{
		ans++;
	}

	cout << ans << endl;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, a = 0, b = 0, ans = 0,ab = 0;
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'B' && s[s.size() - 1] == 'A') ab++;
		else if (s[0] == 'B') b++;
		else if (s[s.size() - 1] == 'A') a++;
		rep(j,s.size()-2){
			if (s[j] == 'A' && s[j + 1] == 'B') ans++;
		}
	}
	//cout << a << " " << b << " " << ab << endl;
	if (a == 0 && b == 0 && ab == 0) {
		cout << ans << endl;
	}
	else if (a == 0 && b == 0) {
		cout << ans + ab - 1 << endl;
	}
	else {
		cout << ans + min(a + ab, b + ab) << endl;
	}

	return 0;
}


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

ll beki[222];
int used[222][222];

int main(){
  beki[0]=1;
  rep(i,202) beki[i+1]=beki[i]*2%MOD;
  ll N; cin>>N;
  ll X[N],Y[N]; rep(i,N) cin>>X[i]>>Y[i];
  ll ans=(beki[N]-1-N-N*(N-1)/2+MOD)%MOD;
  rep(i,N) rep(j,i) if(used[i][j]==0){
    vector<int> V;
    V.push_back(i);
    V.push_back(j);
    rep(k,N) if(k!=i&&k!=j){
      if((X[k]-X[j])*(Y[i]-Y[j])-(X[i]-X[j])*(Y[k]-Y[j])==0) V.push_back(k);
    }
    ll n=V.size();
    rep(k,n) rep(l,n) used[V[k]][V[l]]=1;
    if(n>=3) ans=(ans+MOD-beki[n]+1+n+n*(n-1)/2)%MOD;
  }
  cout<<ans%MOD<<endl;
  return 0;
}


Measured memory_bytes: 384
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
#include<bits/stdc++.h>
using namespace std;
#define MAX 1e6+10
#define MOD 1000000007
#define PI 3.14159265359
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool prime[1000001];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    makefast__
    string str;
    ll i,j,n,m,k,t,c;
    cin>>str;
    if(str.find("RRR")!=str.npos)
    {
        cout<<3<<endl;
        return 0;
    }
    if(str.find("RR")!=str.npos)
    {
        cout<<2<<endl;
        return 0;
    }
    if(str.find("R")!=str.npos)
    {
        cout<<1<<endl;
        return 0;
    }
    cout<<0<<endl;

    return 0;
}




Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = s.size();


  if (n % 2 == 0) {
    cout << "No" << endl;
    return 0;
  }else if(n == 3){
    if (s[0] != s[2]){
      cout << "No" << endl;
      return 0;
    }

  }else{
    for (int i = 0; i<n/4; i++) {
      if (s[i] != s[((n-1)/2) - (i+1)]){
        cout << "No" << endl;
        return 0;
      }
      if ( s[((n+3)/2) -1 + i] != s[n - (1+i)] ){
        cout << "No" << endl;
        return 0;
      }
      
    }
    for (int i=0; i<n/2; i++){
      if (s[i] != s[n-(1+i)]){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

int main() {
	string S;
	cin >> S;
	int i;
	int c[26] = {};
	for (i = 0; i < S.size(); i++) {
		c[S[i] - 'a']++;
	}
	for (i = 0; i < 26; i++) {
		if (c[i] > 1){ 
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
	Time created : 10/14/2019 2:24
	Name : B - Roller Coaster
	Author : Minh Duc Phung - Team4 - ITPTIT
*/
#include<bits/stdc++.h>

#define fi first  
#define se second
#define mp make_pair
#define pb push_back
 
using namespace std;
typedef long long i64;
typedef pair < int,int > pii;
typedef vector <int> vi;
typedef vector <vi> vii;

const int N = 1e5+5;
const i64 mod = 1e9+7;
const i64 inf = LLONG_MAX;

inline i64 Gcd(i64 a, i64 b) {i64 r; while(b){ r = a % b; a = b; b = r;} return a;}
inline i64 modPow(i64 n, i64 k) {i64 r=1; for(;k;k>>=1,n=n*n%mod){if(k&1)r=r*n%mod;}return r;}
inline i64 C(int k, int n){i64 r=1;for(int i=1;i<=k;i++,n--)r=r*n%mod*modPow(i,mod-2)%mod;return r%mod;}

int dx[] = {-1,0,0,1};
int dy[] = {0,-1,1,0};
int n,k,cnt = 0;
vi a;
void input(){
	cin >> n >> k;
	a.resize(n);
	for ( auto &x : a ){
		cin >> x;
		if ( x >= k ) cnt++; 
	}
}
 
void solve(){
	cout << cnt;
}
int main(){
	//freopen("INPUT.in", "r", stdin);
    //freopen("OUTPUT.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin>>t;
	while(t--){input(); solve();}
	return 0;
}

  

Measured memory_bytes: 640
n=int(input())
s=list(input())
a=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(s)):
  for j in range(26):
    if s[i]==a[j]:
      s[i]=a[((j+n)%26)]
      break
print(*s,sep="")

Measured memory_bytes: 4852
S = input()
T = input()

ans = []
sl = len(S)
tl = len(T)
for i in range(sl-tl+1):
	if S[i] == '?' or S[i] == T[0]:
		flg = True
		for j in range(1,tl):
			if S[i+j] != '?' and S[i+j] != T[j]:
				flg = False
				break

		if flg:
			s = S[:i] + T + S[i+tl:]
			ans.append(s.replace('?','a'))

if ans == []:
	print("UNRESTORABLE")
	exit(0)

ans.sort()
print(ans[0])


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s,t,u;
  cin>>s>>t>>u;
  cout<<s[0]<<t[1]<<u[2]<<endl;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

void Eratosthenes(int n, vector<int> &primeNum)
{
    vector<bool> sieve(n, true);
    for (int i = 2; i < sqrt(n); i++)
    {
        if (sieve[i])
        {
            for (int j = 0; i * (j + 2) < n; j++)
            {
                sieve[i * (j + 2)] = false;
            }
        }
    }
    int count = 0;
    for (int i = 2; i < n; i++)
    {
        if (sieve[i])
        {
            primeNum.push_back(i);
            count++;
        }
    }
}
int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int x;
    cin >> x;
  
    vector<int> prime;
    Eratosthenes(x, prime);
    int res = 0;
    for (int i = x;; i++)
    {
        bool flag = true;
        for (int p : prime)
        {
            if (i % p == 0)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            res = i;
            break;
        }
    }
    c(res);
    
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  string ans="";
  for(int i=0;i<N;i++){
  ans+=S.at(i);
  ans+=T.at(i);
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
balls = []

# 初期位置を覚えておく
placeB = [0] * N
placeW = [0] * N

# 入力処理 & 初期位置処理
for i in range(2*N):
    c, a = input().split()
    a = int(a)
    balls.append([c, a])
    if c == "B":
        placeB[a-1] = i
    else:
        placeW[a-1] = i


costB = [[0]*(2*N+1) for i in range(N+1)]  # i番目まででjより大きいB
costW = [[0]*(2*N+1) for i in range(N+1)]  # i番目まででjより大きいW

for i in range(N):
    for j in range(2*N):
        if balls[j][1] > i:
            if balls[j][0] == "B":
                costB[i][j+1] = 1
            else:
                costW[i][j+1] = 1

# 累積和
costB = [list(accumulate(cB)) for cB in costB]
costW = [list(accumulate(cW)) for cW in costW]

# dp
dp = [[float('inf')]*(N+1) for i in range(N+1)]
dp[0][0] = 0
for b in range(N+1):
    for w in range(N+1):
        if b > 0:
            dp[b][w] = min(dp[b][w], dp[b-1][w] + costB[b][placeB[b-1]] + costW[w][placeB[b-1]])
        if w > 0:
            dp[b][w] = min(dp[b][w], dp[b][w-1] + costW[w][placeW[w-1]] + costB[b][placeW[w-1]])

print(dp[N][N])


Measured memory_bytes: 407104
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 1e5+3;
ll n,S,x[N],p[N],ans[N];

int main(){
    scanf("%lld %lld",&n,&S);
    rep(i,1,n) scanf("%lld %lld",&x[i],&p[i]);
    int l=1,r=n;
    rep(i,1,n){
        if(x[r]<S) ans[i]=x[l];
        else if(x[l]>S) ans[i]=x[r];
        else{
            if(p[l]<p[r]) ans[i]=x[l],p[r]+=p[l++];
            else ans[i]=x[r],p[l]+=p[r--];
        }
    }
    ll out=0;
    per(i,n,1) out+=abs(S-ans[i]), S=ans[i];
    printf("%lld\n",out);
    return 0;
}

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



int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  //角度
  double radian = abs( (2.0 * M_PI) / 60.0 * M - (2.0 * M_PI) / (12.0*60) * (M+60*H));
  
  //余弦定理
  cout << fixed << setprecision(9) << sqrt( A*A+B*B-2.0*A*B*cos(radian) ) << endl;


  return 0;
}

Measured memory_bytes: 4180
n = int(input())
A =[0] + [int(input()) for _ in range(n)]
q = [1]
cnt = 0
for i in range(1,n+2):
    x = q.pop(0)
    if x ==2:
        print(cnt)
        exit()
    q.append(A[x])
    cnt += 1
print(-1)

Measured memory_bytes: 7852
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define abs(x)      ((x)>0?(x):-(x))
#define Mul(x,y)    (x=(x)*(y)%mod)
#define Mul1(x,y)   (x=(x)*(y)%mod1)
#define Add(x,y)    (x=(x+(y))%mod)
#define Add1(x,y)	(x=(x+(y))%mod1)
#define E(x)        return writeln(x),0
#define p(x)        printf("~%d~\n",x)
#define pp(x,y)     printf("~~%d %d~~\n",x,y)
#define ppp(x,y,z)  printf("~~~%d %d %d~~~\n",x,y,z)
#define pppp(x,y,z,a)  printf("~~~%d %d %d %d~~~\n",x,y,z,a)
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif
#define NEG 1
    inline char gc(){   return getchar();   }
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
    inline ld getreal(){    static ld lbc;  scanf("%lf",&lbc);  return lbc; }
}using namespace SHENZHEBEI;
const ll N=1000;
map<vector<ll>,ll>mp;
vector<ll>p;
char s[N];
ll all,n;
long long ans;
int main(){
	n=read();
	readstr(s+1);
	all=(1<<n)-1;
	For(S,0,all){
		p.clear();
		For(i,1,n)if(S>>(i-1)&1)
			p.push_back(s[i]);
		p.push_back('*');
		For(i,1,n)if(!(S>>(i-1)&1))
			p.push_back(s[i]);
		++mp[p];
	}
	For(S,0,all){
		p.clear();
		For(i,1,n)if(S>>(i-1)&1)
			p.push_back(s[2*n-i+1]);
		p.push_back('*');
		For(i,1,n)if(!(S>>(i-1)&1))
			p.push_back(s[2*n-i+1]);
		ans+=mp[p];
	}printf("%lld\n",ans);
}
/*
A
A-B
A-2B
A-3B
A
*/

Measured memory_bytes: 90368
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll 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 rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int dp[2][525][505];

int main(){
	int n,x; cin >> n >> x;
	rep(k,x+1) dp[1][0][k] = 1;
	rep(i,n){
		rep(j,512){
			rep(k,x+1){
				dp[i&1][j^k][k] += dp[!(i&1)][j][k];
				dp[i&1][j^k][k] %= mod;
			}
		}
		rep(j,512){
			rep(k,x) dp[i&1][j][k+1] += dp[i&1][j][k], dp[i&1][j][k+1] %= mod;
			rep(k,x+1) dp[!(i&1)][j][k] = 0;
		}
	}
	cout << dp[!(n&1)][x][x] << endl;
}


Measured memory_bytes: 5136
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

int main(){
    long n;
    cin >> n;
    vector<int> P(n);
    vector<int> Q(n);
    vector<int> prm(n);
    for(auto & e :P) cin>>e;
    for(auto & e :Q) cin>>e;
    int inc=0;
    for(auto & e :prm) e=++inc;
    // make permutation
    int pi=0;
    int qi=0;
    int cnt=1;
    do{
        if(prm==P) pi=cnt;
        if(prm==Q) qi=cnt;
        cnt++;
    }while(next_permutation(prm.begin(),prm.end()));

    cout << abs(pi-qi) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define MAX 80000
using namespace std;

int main(){
	int n;
	int prime[MAX],i,j;
	int count;
	bool flag;

	while((cin >> n)!= NULL){
		count = 0;
		for(i = 3; i <= n; i+=2){
			flag = true;
			for(j = 0; j < count; j++){
				if(i % prime[j] == 0){
					flag = false;
					break;
				}
				if(prime[j] * prime[j] > i) break;
			}
			if(flag == true){
				prime[count++] = i;
			}
		}
		if(n > 1)	count++; //2
		cout << count << endl;
		//delete[] prime;
	}
	return 0;
}

Measured memory_bytes: 1472
#include <bits/stdc++.h>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
int main(){
	ios::sync_with_stdio(false);
	int a,b,c,x;cin>>a>>b>>c>>x;
	int ans=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(500*i+100*j+50*k==x) ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int main() {
    fastio();
    ll X, Y;
    cin >> X >> Y;
    cout << (abs(X-Y)>1?"Alice":"Brown") << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    int white = H * W;
    int black = h*W + w*H - h*w;
    System.out.print(white - black);
  }
}

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

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define klar(v) memset(v, 0, sizeof(v))
#define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a, b) __gcd(a, b);
#define debug(x) cout << #x << " " << x << endl;
#define endl "\n"

typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const int maxn = 1e5+100;

int arr[maxn];

int main(){
    bust
    int n, k;
    cin >> n >> k;
    vi left, right;
    int l = 0, r = k-1;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        if(arr[i] <= 0)left.pb(arr[i]);
        else right.pb(arr[i]);
    }
    int ans = INT_MAX;
//    if(n == 1){
//
//    }??
    for(int i = 0; i <= n-k; i++){
//        cout << arr[i] << " " << arr[i+k-1] << endl;
        if(1LL*arr[i]*arr[i+k-1] >= 0){
            ans = min(max(abs(arr[i]), abs(arr[i+k-1])), ans);
        }
        else{
            ans = min(ans, abs(arr[i])+abs(arr[i+k-1]-arr[i]));
            ans = min(ans, abs(arr[i+k-1])+abs(arr[i+k-1]-arr[i]));
        }
    }
    cout << ans;
}


Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int dp[1010][5000]; //dp[i][j] = i番目までのカギを使ってjの状態にするための最小コスト

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> key(M);
    vector<int> cost(M);
    for(int i = 0;i < M;i++) {
        int A;
        cin >> cost.at(i) >> A;
        for(int j = 0;j < A;j++) {
            int B;
            cin >> B;
            B--;
            key.at(i) += (1 << B);
        }
    }
    for(int i = 0;i < 1010;i++) {
        for(int j = 0;j < 5000;j++) {
            dp[i][j] = Inf;
        }
    }
    dp[0][0] = 0;
    for(int i = 0;i < M;i++) {
        for(int j = 0;j < (1 << N);j++) {
            dp[i + 1][j] = min(dp[i + 1][j],dp[i][j]); //i + 1番目の鍵を使わない場合
            dp[i + 1][j | key.at(i)] = min(dp[i + 1][j | key.at(i)],dp[i][j] + cost.at(i)); //i + 1番目の鍵を使う場合
        }
    }
    if(dp[M][(1 << N) - 1] == Inf) {
        cout << -1 << endl;
    }
    else {
        cout << dp[M][(1 << N) - 1] << endl;
    }
}

Measured memory_bytes: 19968
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int l[q], r[q];
    rep (i, q) cin >> l[i] >> r[i];

    s = 'x' + s;

    vector<int> sum(n + 1, 0);

    for (int i = 1; i <= n - 1; i++) {
        if (s[i] == 'A' && s[i + 1] == 'C') sum[i + 1]++;
    }
    
    //printa(sum, n + 1);
    for (int i = 2; i <= n; i++) {
        sum[i] += sum[i - 1];
    }
    //printa(sum, n + 1);
    rep (i, q) {
        cout << sum[r[i]] - sum[l[i]] << endl; 
    }
    return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define viit vector<int>::iterator
#define MOD 1000000007
#define endl "\n"
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define repd(i, a, b) for (int i = (a); i >= (b); i--)
#define modm(a, m) (((a) % m + m) % m)
#define mod(a) modm(a, MOD)
#define op_mod(op, a, b) mod(mod(a) op mod(b))

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, W;
    cin >> n >> W;
    vll dp(1e5 + 1, 1e18);
    dp[0] = 0;
    int w, v;
    repe(i, 1, n) {
        cin >> w >> v;
        repd(j, i * 1000, v) {
            dp[j] = min(dp[j], dp[j - v] + w);
        }
    }
    repd(i, 1e5, 1) {
        if (dp[i] <= W) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


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

void Main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int x = (h2 - h1) * 60 + (m2 - m1) - k;
    cout << x << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a, b, k;
  cin>>a>>b>>k;
  if (k <= a) {
    cout<<a-k<<" "<<b<<endl;
  }
  else if (k <= (a+b)) {
    cout<<0<<" "<<a+b-k<<endl;
  }
  else cout<<0<<" "<<0<<endl;
}

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

int N;
int V[51], C[51], D[51];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> V[i];
    for (int i = 0; i < N; i++) cin >> C[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        D[i] = V[i] - C[i];
        if (D[i] > 0) ans += D[i];
    }

    cout << ans;
}

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


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

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

int main() {
  ll a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
}

Measured memory_bytes: 3632
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
constexpr int inf=(1<<30)-1;
constexpr ll mod=1e9+7;



int main(){
  int n;
  cin>>n;
  double x[n],y[n];
  rep0(i,n) cin>>x[i]>>y[i];
  double t[n];
  rep0(i,n){
      t[i]=atan2(y[i],x[i]);
      //cout<<t[i]<<endl;
  }
  pair<double,pair<double,double>> q[n];
  rep0(i,n) q[i]={t[i],{x[i],y[i]}};
  sort(q,q+n);
  double ans=0;
  rep0(i,n){
    double posx=0;
  	double posy=0;
  	double pos=0;
    rep0(j,n){
      int k=(i+j)%n;
      int xx=q[k].second.first;
      int yy=q[k].second.second;
      posx+=xx;
      posy+=yy;
      pos=posx*posx+posy*posy;
      ans=max(ans,pos);
    }
  }
  cout<<setprecision(15)<<sqrt(ans)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#define FOR(a,b,c) for(int a=(b);a<=(c);a++)
using namespace std; 
const int maxn = 100+10; 
char G[maxn][maxn];
int n,m;
int A(int i,int j) {
     return G[i][j]=='#'?1:0;
 }
 int main() {
     cin>>n>>m;
     FOR(i,1,n) FOR(j,1,m) cin>>G[i][j];
     FOR(i,1,n) {
         FOR(j,1,m) {
             if(G[i][j]=='#') cout<<'#';
             else 
             {
                 int ans=A(i-1,j-1)+A(i-1,j)+A(i-1,j+1)+A(i,j-1)+A(i,j+1)+A(i+1,j-1)+A(i+1,j)+A(i+1,j+1);
                 cout<<ans;
             }
         }
         cout<<endl;
     }
     return 0;
 }

Measured memory_bytes: 256
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0

n,k,q = map(int,input().split())
p = [k-q] * n
for i in range(q):
    p[iin()-1]+=1
for i in range(n):
    if p[i] > 0:
        py()
    else:
        pn()

Measured memory_bytes: 11672
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll dx[] = { 1,0,-1,0 }, dy[] = { 0,-1,0,1 };
char c[55][55];
int main() {
	ll h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; i++)for (int j = 1; j <= w; j++)cin >> c[i][j];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '#') {
				bool f = 0;
				for (int k = 0; k < 4; k++) {
					if (c[i + dy[k]][j + dx[k]] == '#')f = 1;
				}
				if (!f) {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

import fileinput

def main():
    for line in fileinput.input():
        tokens = list(map(int, line.strip().split()))
        a, b = tokens[0], tokens[1]

        if a < b:
            a, b = b, a

        ansGCD = GreatestCommonDivisor(a, b)
        ansLCM = LeastCommonMultiple(a, b)

        print('{0} {1}'.format(ansGCD, ansLCM))

def GreatestCommonDivisor(a, b):
    while b:
        a, b = b, a%b

    return a

def LeastCommonMultiple(a, b):
    return (a*b) / GreatestCommonDivisor(a, b)


if __name__ == '__main__':
    main()

Measured memory_bytes: 6396
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String[] b = a.split("");
    int count = 0;
    for(int i = 0; i < b.length; i++){
      if(b[i].equals("1")){
        count++;
      }
    }
    System.out.println(count);
  }
}
      

Measured memory_bytes: 21972
var
 t,n,i,j,sum:longint;
 a:array[0..10001] of longint;
begin
 readln(n);
 for i:=1 to 2*n do
  read(a[i]);
 for i:=1 to 2*n-1 do
  for j:=i+1 to 2*n do
   if a[i]<a[j] then 
    begin
     t:=a[i]; a[i]:=a[j]; a[j]:=t; 
    end;
 j:=1;
 for i:=1 to n do
  begin
   sum:=sum+a[j+1];
   j:=j+2;
  end;
 writeln(sum);
end.

Measured memory_bytes: 128
#include<stdio.h>

char tmp[10],s[12][13];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};

int dxy(int x,int y)
{
  int i;
  if(0>x||x>11||0>y||y>11||s[y][x]!='1') return 0;
  s[y][x]='0';
  for(i=0; i<4; i++){
    dxy(x+dx[i],y+dy[i]);
  }
  return 1;
}

int main()
{
  int y,x,i,n;
  while(scanf("%s",s[0]) != -1)
    {
      n=0;
      for(i=1;i<12;i++){
	scanf("%s",s[i]);
      }
      //scanf("\n");
      for(y=0;y<12;y++){
	for(x=0;x<12;x++){
	  n+=dxy(x,y);
	}
      }
      printf("%d\n",n);
    }
  return 0;
}

Measured memory_bytes: 540
#include<cstdio>
#include<vector>
#include<complex>
#include<utility>
using namespace std;
const double eps = 1e-10;
typedef complex<double> Point;
typedef Point Vector;
pair <Point,Point> Line1,Line2;

double dot(Point& a,Point& b)
{
    return real(conj(a)*b);
}

double cross(Point& a, Point& b)
{
    return imag(conj(a)*b);
}

int ccw(Point& a, Point& b, Point& c)
{
    Point t1 = b - a, t2 = c - a;
    if (cross(t1, t2) > 0)   return +1;       // counter clockwise
    if (cross(t1, t2) < 0)   return -1;       // clockwise
    if (dot(t1, t2) < 0)     return +2;       // c--a--b on line
    if (norm(t1) < norm(t2)) return -2;       // a--b--c on line
    return 0;
}

bool isintersaction(pair <Point,Point> a, pair <Point,Point> b)
{
    return (ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0 && ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0);
}

int main()
{
    int vol;
    scanf("%d",&vol);
    while(vol--)
    {
        int x0, y0, x1, y1, x2, y2, x3, y3;
        scanf("%d%d%d%d%d%d%d%d",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3);
        Line1 = make_pair(Point(x0, y0), Point(x1, y1)), Line2 = make_pair(Point(x2, y2), Point(x3, y3));
        printf("%d\n",isintersaction(Line1, Line2));
    }
    return 0;
}

Measured memory_bytes: 1048
# 入力
N = int(input())
a = [int(input()) for _ in range(N)]

# aの要素がすべて奇数ならば、かつ、そのときに限りルンルンが勝つ
ans = (
    'first' if any(x % 2 == 1 for x in a) else
    'second'
)

# 出力
print(ans)


Measured memory_bytes: 7072
#include <bits/stdc++.h>
#define ll long long
#define pb push_back;
using namespace std;
ll cnt,mini=1e9,maxi=-1;
ll n,m,k,x;
ll mini1=1e9,maxi1=-1,cnt1,cnt2,cnt3,ans,sum;
int main(){
ios_base::sync_with_stdio(0);
	// freopen (" .txt", "r", stdin);
	// freopen (" .txt", "w", stdout);
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0; i<n-1; i++){
		if(a[i]==a[i+1]){
			cout<<"NO";
		return 0;
		}
	}
	cout<<"YES";
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
typedef complex<double> point;

const int N = 1e4 + 10;
int n;
ll a[N], b[N];

int main() {

	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	for(int i = 0; i < n; ++i)
		scanf("%lld", b + i);
	ll cnt = 0;
	for(int i = 0; i < n; ++i)
		cnt += max(0LL, a[i] - b[i]);
	for(int i = 0; i < n && cnt; ++i) {
		ll x = max(0LL, b[i] - a[i]);
		x /= 2;
		x = min(x, cnt);
		cnt -= x;
		a[i] += 2 * 1LL * x;
	}
	puts(cnt ? "No" : "Yes");

	return 0;
}

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

using namespace std;

typedef long long ll;

const ll P1 = 43;
const ll P2 = 41;
const ll MOD = 1e9+7;

bool valid(vector<vector<pair<int, int>>> &dp, int len, int n){
    set<pair<pair<int, int>, int >> st;

    for(int i = 0; i+len <= n; i++){
        auto lb = st.lower_bound({dp[i][len], -1});
        if( (*lb).first != dp[i][len] )
            st.insert({dp[i][len], i});
        else
            if( (*lb).second+len <= i )
                return true;
    }

    return false;
}

int main(){

    int n;
    string s;
    cin >> n >> s;
    vector<ll> pw1(n+1), pw2(n+1);
    pw1[0] = 1, pw2[0] = 1;
    for(int i = 1; i <= n; i++){
        pw1[i] = (pw1[i-1]*P1)%MOD;
        pw2[i] = (pw2[i-1]*P2)%MOD;
    }
    
    vector<vector<pair<int, int>>> dp(n+1, vector<pair<int, int>>(n+1));
    for(int i = 0; i < n; i++){
        ll hash1 = 0, hash2 = 0;
        for(int j = i, len = 1; j < n; j++, len++){
            hash1 = ( hash1 + (s[j]-'a'+1)*pw1[len-1] )%MOD;
            hash2 = ( hash2 + (s[j]-'a'+1)*pw2[len-1] )%MOD;
            dp[i][len].first = hash1;
            dp[i][len].second = hash2;
        }
    }

    int lw = 0, hg = n/2;
    while(lw < hg){
        int md = (lw + hg + 1)/2;
        if( valid(dp, md, n) )
            lw = md;
        else
            hg = md-1;
    }

    cout << lw << endl;
    return 0;
}

Measured memory_bytes: 196224
#include<cstdio>


int main(){
	int n, t;
	int f[50101] = {};

	for(int i = 2; i < 25051; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 224; i += 2){
		for(int j = 3; j * i <= 50100; j += 2){
			f[i * j] = 1;
		}		
	}

	while(scanf("%d", &n) + 1){
		t = n - 1;
		while(f[t]){
			t--;
		}
		printf("%d ", t);
		t = n + 1;
		while(f[t]){
			t++;
		}
		printf("%d\n", t);
	}
	return 0;
}

Measured memory_bytes: 1224
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define INF 1LL << 61
#define MAX (1LL << 31) -1
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> pi;
//typedef pair<pair<int,int>,ll> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
template<class T,class U>bool inline chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool inline chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

int N;
vector<int> a,b;
int C[100010];

signed main(){
    cin>>N;
    a.resize(N); b.resize(N);
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<N;i++){
        C[a[i]]++;
        C[b[i]+1]--;
    }
    for(int i=1;i<=N+1;i++){
        C[i]+=C[i-1];
    }
    int ans=0;
    for(int i=1;i<=N+1;i++){
        if(C[i]>=i-1) chmax(ans,i-1);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 4036