akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
vector<int> a;

void mainmain(){
    cin >> n;
    for (int i = 0;i < n; i++){
        int m;
        cin >> m;
        a.push_back(m);
    }
    
    int min = *min_element(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());

    cout << max - min << endl;
}

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

Measured memory_bytes: 256
k, n = tuple(map(int, input().split()))
a = list(map(int, input().split()))

tmp = a[-1] - a[0]
for i in range(n-1):
    if (k+a[i]) - a[i+1] < tmp:
            tmp = (k+a[i]) - a[i+1]

print(tmp)


Measured memory_bytes: 26420
n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1

max_value = max(s_dic.values())
s_dic = sorted(s_dic.items(), key=lambda x:x[0])

for i in s_dic:
    if i[1] == max_value:
        print(i[0])

Measured memory_bytes: 46236
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
ans = '{}:'.format(n)

prime_factors = []
i = 2
while i ** 2 <= n:
    ext = 0
    while n % i == 0:
        ext += 1
        n //= i
    if ext:
        prime_factors.append((i, ext))
    i += 1

if n != 1:
    prime_factors.append((n, 1))

for pf, num in prime_factors:
    ans = '{} {}'.format(ans, ' '.join([str(pf)] * num))

print(ans)



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main() {
	string n; cin >> n;
	int res;
	bool nine = true;
	for (int i = 1; i < n.size(); i++)
	{
		if(n[i] != '9') nine = false;
	}

	if(n.size() == 1) res = n[0] - '0';
	else if(nine) res = 9 * (n.size() - 1) + n[0] - '0';
	else res = 9 * (n.size() - 1) + n[0] - '1';
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3652
x,y = map(int,input().split())
i = 0
if 2*x == y:
    print('Yes')
else:   
    while True:
        ashi = 2 * i + 4 * (x-i)
        if ashi == y:
            print('Yes')
            break
        if i==x-1:
            print('No')
            break
        i = i + 1

Measured memory_bytes: 9200
#include <iostream>
 
using namespace std;
 
int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  
  int count = 0;
  int num = min(A, B);
  while(1)
  {
    if(A % num == 0 && B % num == 0) count++;
    if(count == C) break;
    num--;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn = 3e5 + 10;
using namespace std;

int n, m, T, kase = 1;
int a[maxn], pre[maxn];

int findset(int x) { return x == pre[x] ? x : pre[x] = findset(pre[x]); }

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++) pre[i] = i;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int ans = 0;
	while(m--) {
		int u, v; cin >> u >> v;
		pre[findset(u)] = findset(v);
	}
	for(int i = 1; i <= n; i++) if(findset(i) == findset(a[i])) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//std::ios::sync_with_stdio(false);

main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n,l,minn=inf,i,fl=0,s=0;
	cin>>n>>l;
	f(i,1,n+1){
		if(abs(l+i-1)<minn){
			minn=abs(l+i-1);
			if(l+i-1<0){
				fl=1;
			}
			else{
				fl=0;
			}
		}
		s+=l+i-1;
	}	
	if(fl){
		s+=minn;
	}
	else{
		s-=minn;
	}
	cout<<s<<endl;
	return 0;
} 
	

Measured memory_bytes: 256
#include<math.h>
M;
X[100][4],Y[100][4],P[100];
//_O(X[o][i],Y[o][i]),_A(X[a][j],Y[a][j]),_B(X[b][k],Y[b][k])Æµ½Æ«ÌAOÏOA~OB
long long cross(o,i,a,j,b,k){
	return (X[a][j]-X[o][i])*(Y[b][k]-Y[o][i])-(Y[a][j]-Y[o][i])*(X[b][k]-X[o][i]);
}
//C~l[VaÌüªi`i+1ÌãÉA_(X[b][j],Y[b][j])ª é©»è
is_point_online(a,i,b,j){
	int i2=(i+1)%4;
	return hypot(X[a][i]-X[b][j],Y[a][i]-Y[b][j])+hypot(X[a][i2]-X[b][j],Y[a][i2]-Y[b][j])
		<hypot(X[a][i]-X[a][i2],Y[a][i]-Y[a][i2])+1e-9;
}
//C~l[VaÌüªi`i+1ÆAC~l[VbÌüªj`j+1Ìð·»è
is_intersected_ls(a,i,b,j){
	int i2=(i+1)%4,j2=(j+1)%4;
	if(is_point_online(a,i,b,j)||is_point_online(a,i,b,j2)||
		is_point_online(b,j,a,i)||is_point_online(b,j,a,i2))
		return 1;
	return cross(a,i,a,i2,b,j)*cross(a,i,a,i2,b,j2)<0&&
		   cross(b,j,b,j2,a,i)*cross(b,j,b,j2,a,i2)<0;
}
//_(X[b][i],Y[b][i])ªC~l[VaÌàÉ é©H
is_internal_ill(a,b,i){
	int j,r=1;
	for(j=0;j<4;j++)
		if(cross(b,i,a,j,a,(j+1)%4)>0)
			r=0;
	return r;
}
//C~l[Va,bªAµÄ¢é©H
is_intersected_ill(a,b){
	int i,j;
	//Ý¢Éð··éÓª êÎA
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
			if(is_intersected_ls(a,i,b,j))
				return 1;
	for(i=0;i<4;i++)
		if(is_internal_ill(a,b,i)||//bÌ¸_ª1ÂÅàaÌàÉ êÎA
		   is_internal_ill(b,a,i))//aÌ¸_ª1ÂÅàbÌàÉ êÎA
			return 1;
	return 0;
}
//C~l[VmÆ»êÉAµÄ¢éSC~l[Vð_
/*
Power(m){
	int Q[100],q,i;
	q=m;
	Q[q]=-1;
	P[m]=0;
	for(;m>=0;){
		for(i=m;++i<M;){
			if(P[i]&&is_intersected_ill(m,i)){
				P[i]=0;
				q=Q[q]=i;
				Q[q]=-1;
			}
		}
		m=Q[m];
	}
}*/
Power(m){
	int i;
	P[m]=0;
	for(i=0;i<M;i++)
		if(P[i]&&is_intersected_ill(m,i))
			Power(i);
}
main(){
	int N,i,j,c;
	for(;scanf("%d",&N),N;){
		for(;N--;){
			scanf("%d",&M);
			for(i=0;i<M;i++){
				for(j=0;j<4;j++)
					scanf("%d%d",&X[i][j],&Y[i][j]);
				P[i]=1;
			}
			c=0;
			for(i=0;i<M;i++){
				if(P[i]){
					Power(i);
					c++;
				}
			}
			printf("%d\n",c);
		}
	}
	exit(0);
}

Measured memory_bytes: 424
n = int(input())

cList = []
for i in range(1,n):
  cal = n//i
  if i > cal:
    break
  if n % i == 0:
    cList.append([i,cal])

sL = n
for i in range(len(cList)):
  sT = max(len(str(cList[i][0])),len(str(cList[i][1])))
  if sL > sT:
    sL = sT

print(sL)

  

Measured memory_bytes: 3188
n = gets.chomp.to_i
p_arr = gets.chomp.split(" ").map(&:to_i)
q_arr = gets.chomp.split(" ").map(&:to_i)

a = nil
b = nil
(1..n).to_a.permutation.to_a.each_with_index do |arr, i|
  if a.nil? && p_arr == arr
    a = i
  end
  if b.nil? && q_arr == arr
    b = i
  end
end

puts (a - b).abs


Measured memory_bytes: 20572
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        v: [i64; n],
    }

    let mut v = v;

    for x in (0..n - 1).rev() {
        if v[x] > v[x + 1] {
            v[x] -= 1;
        }
        if v[x] > v[x + 1] {
            println!("No");
            return;
        }
    }

    println!("Yes");
}


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

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

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

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n;
    cin >> n;
    FOR(a, -2000, 2000){
        FOR(b, -2000, 2000){
            if(n == a*a*a*a*a - b*b*b*b*b){
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int p[114514];
signed main(){
	int i,j;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>p[i];
	sort(p,p+n);
	p[n]=191919191919419;
	n++;
	int l=0,u=0;
	int ans=0;
	for(i=0;i<n;i++)
		if(p[i]!=u){
			ans+=(i-l)%2;
			l=i;
			u=p[i];
		}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n; long long c, k, t[100010];
	cin >> n >> c >> k;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	sort(t, t + n);
	int bus = 0;
	long long person = 1;
	long long time_lim = t[0] + k;
	for (int i = 1; i < n; i++) {
		if (t[i] > time_lim || person >= c) {
			bus++;
			person = 1;
			time_lim = t[i] + k;
		}
		else {
			person++;
		}
	}
	cout << bus+1 << endl;
	return 0;
}

Measured memory_bytes: 1024
data_hash = {}
while line = gets
  word, index = line.split " "
  data_hash[word] ||= []
  data_hash[word] << index
end

data_hash.keys.sort.each do |key|
  puts key+"\n"
  puts data_hash[key].map(&:to_i).sort.join(" ") + "\n"
end

Measured memory_bytes: 6088
/**  elias **/
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long double
#define pb push_back
#define sz size
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define F first
#define S second
#define ld long double
#define ll long long
#define pb push_back
#define sz size
using namespace std;
const ll mod=1e9+7;
const int N=1e6+10;
ll f[N],inv[N];
ll pow_(ll a,ll b,ll mod=1e9+7){
    ll ans=1ll;
    while(b){
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

void init(){
    f[0]=inv[0]=1;
    for(int i=1; i<N; i++){
            f[i]=1ll*i*f[i-1]%mod,inv[i]=pow_(f[i],mod-2);
    }
}

ll C(int n,int m){
    return f[n]*inv[n-m]%mod*inv[m]%mod;
}
ll num_of_way(int xa,int ya,int xb,int yb){
	int xx=abs(xa-xb);
	int yy=abs(ya-yb);
	return C(xx+yy,xx);
}
int main(){
init();
ll n,m,a,b;
scll(n);scll(m);scll(a);scll(b);
ll ans=0;
loop(i,1,n-a){
	ans+=(num_of_way(1,1,i,b)*num_of_way(i,b+1,n,m))%mod;
	ans%=mod;	
}
printf("%lld\n",ans);
}


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

int main()
{
  int k, n, max = 0;
  vector<int> a;
  cin >> k >> n;
  for (int i = 0; i < n; i++)
  {
    int t;
    cin >> t;
    a.push_back(t);
    if (t - a[i - 1] > max)
    {
      max = t - a[i - 1];
    }
  }

  if (k + a[0] - a[n - 1] > max)
  {
    max = k + a[0] - a[n - 1];
  }

  cout << k - max << endl;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int k,x;
    scanf("%d %d",&k,&x);
    for (int i = 0; i < 2 * k - 1; i++) {
        printf("%d ",x - k + i + 1);
    }
    printf("\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b == 0)
    {
        cout << "0" << endl;
        return 0;
    }
    if (b / a >= c)
    {
        cout << c << endl;
    }
    else
    {
        cout << b / a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<sstream>
#include<cctype>
#include<cstdlib>
#include<map>
#include<queue>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const double INF = 1000000000;

class C{
    public:
        int now, used;
        double cost;
        C(int n, double s, int u){
            now = n;
            cost = s;
            used = u;
        }
        bool operator>(const C &c) const{
            return cost > c.cost;
        }
};

int main(){
    int n, m, p, a, b;
    while(cin >>n >>m >>p >>a >>b && n){
        a--;
        b--;
        vector<double> t(n); REP(i, n) cin >>t[i];
        vector< vector<int> > v(m, vector<int>(m, INF));
        REP(i, p){
            int x, y, z; cin >>x >>y >>z;
            x--; y--;
            v[x][y] = z;
            v[y][x] = z;
        }
        //debug
        //REP(i, v.size()){
        //    REP(j, v[i].size()){
        //        printf("%8d ", v[i][j]);
        //    }
        //    cout <<endl;
        //}

        priority_queue< C, vector<C>, greater<C> > open;
        open.push(C(a, 0.0, 0));
        vector< vector<double> > closed(m, vector<double>((1 << n), INF));

        while(!open.empty()){
            //cout <<"-------------------------" <<endl;
            C now = open.top();
            open.pop();

            //debug
            //cout <<now.now <<", " <<now.cost <<", " <<now.used <<endl;

            if(now.cost >= closed[now.now][now.used]) continue;
            closed[now.now][now.used] = now.cost;

            REP(i, m){
                for(int mask = 1, j = 0; mask < (1 << n); mask = (mask << 1), j++){
                    if(v[now.now][i] != INF && (now.used & mask) == 0){
                        int next_used = (now.used | mask);
                        //cout <<"next " <<i <<", " <<now.cost + (v[now.now][i] / t[j]) <<", " <<next_used <<endl;
                        open.push( C(i, now.cost + (v[now.now][i] / t[j]), next_used) );
                    }
                }
            }
        }
        double ans = INF;
        REP(i, closed[b].size()) ans = min(ans, closed[b][i]);
        if(ans == INF) cout <<"Impossible" <<endl;
        else printf("%.3lf\n", ans);
    }
    return 0;
}

Measured memory_bytes: 18832
// Reversing Numbers
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_A
//
// Accepted

use std::io::{BufRead, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();

    let _n: i32 = buf.trim().parse().unwrap();

    buf = String::new();
    stdin.read_line(&mut buf).unwrap();

    let a: Vec<_> = buf.split_whitespace().rev().collect();

    println!("{}", a.join(" "));
}


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

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

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

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

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

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

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

    return (result);
}

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

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll n,k,q;
cin>>n>>k>>q;
vector<ll>ans(n);
for(int i=0;i<n;i++){
    ans[i]=k-q;
}
ll tmp;
for(int i=0;i<q;i++){
   cin>>tmp;
   ans[tmp-1]++;
}
for(auto f:ans){
    if(f>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

}





Measured memory_bytes: 1408
#include <bits/stdc++.h> 
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define PI 3.141592

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N=500,mod=1000000007;
int x,n,y,s,w;
bool vs[N];
int main() { 
	cin.tie(0); cout.tie(0); 
	ios_base::sync_with_stdio();
	cin>>x>>n;
	for (int i=0;i<n;i++) { cin>>y; vs[y]=true; }
	w=mod;
	s=mod;
	for (int i=0;i<=200;i++) if (!vs[i]) if (abs(i-x)<s) { s=abs(i-x); w=i; }
	cout<<w;
	return 0;
}
// Recuerda limites 
// Recuerda casos especiales


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());

		Deque<Integer> deque = new ArrayDeque<Integer>(2000000);
		StringBuilder builder = new StringBuilder();

		for (int i = 0; i < n; i++) {
            String line = reader.readLine();
            if(line.charAt(0) == 'i')
                deque.push(Integer.parseInt(line.substring(7)));
            else if(line.charAt(6)=='F')
                deque.removeFirst();
            else if(line.charAt(6)=='L')
                deque.removeLast();
            else
                deque.remove(Integer.parseInt(line.substring(7)));
        }

		builder.append(deque.poll());
		for(int num : deque)
			builder.append(" ").append(num);
		System.out.println(builder);
	}

}


Measured memory_bytes: 128784
import java.util.*;
/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		if((A-2*B)>0){
			System.out.println(A-2*B);
		}else{
			System.out.println(0);
		}
		sc.close();
	}
};

Measured memory_bytes: 21716
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int a[100010];

map<int, int> mp;

int main(void){
	cin>>n;
	for (int i = 0; i < n; i++) cin>>a[i];

	for (int i = 0; i < n; i++) {
		mp[a[i]]++;
	}

	int kind = mp.size();

	if (kind % 2 == 0) printf("%d\n", kind - 1);
	else printf("%d\n", kind);
	
	return 0;
}

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

const int Nmax = 100010;
int N, M;
int p[Nmax];
int par[Nmax], depth[Nmax];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		depth[i] = 0;
	}
}

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

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

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

int main() {
	cin >> N >> M;
	init(N + 1);
	for (int i = 1; i <= N; i++) cin >> p[i];
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (find(i) == find(p[i])) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
long long cnt[300000] = {};
long long adding[300000] = {};
int main() {
#define int long long
	int n, m;
	cin >> n >> m;
	vector<long long> input;
	REP(i, m) {
		long long tmp;
		cin >> tmp;
		input.push_back(tmp);
	}
	input.push_back(n+1);
	sort(input.begin(), input.end());
	REP(i, input.size()-1) {
		cnt[input[i + 1] - input[i]-1]++;
	}
	long long tools = 0;
	for (int i = 200000; i >= 0; --i) {
		cnt[i] += cnt[i + 1];
		adding[i] += adding[i + 1];
		adding[i] += cnt[i];
	}
	int query;
	cin >> query;
	REP(test, query) {
		long long geko = 0;
		cin >> geko;
		geko -= input[0] - 1;
		if (geko < 0) {
			cout << -1 << endl;
			continue;
		}
		long long top = n-1;
		long long bot = 1;
		while (top - bot > 1) {
			long long mid = (top + bot) / 2;
			if (adding[mid] > geko) {
				bot = mid;
			}
			else {
				top = mid;
			}
		}
		for (int i = max(1LL, (long long)bot - 3);; ++i) {
			if (adding[i] <= geko) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 6880
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();
        int ans = 0;
        if(N%2==0){
            System.out.println(N/2);
        } else {
            System.out.println((N/2)+1);
        }

    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

int32_t main(){
	boost;
	int n;
	cin>>n;
	map<string,int> mpp;
	rep(i,0,n){
		string s;
		cin>>s;
		mpp[s]++;
	}
	int mx=0;
	for(auto el:mpp){
		mx=max(mx,el.s);
	}
	vector<string> v;
	for(auto el:mpp){
		if(el.s==mx){
			v.pb(el.f);
		}
	}
	sort(all(v));
	for(auto x:v){
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 25584
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int x;
	cin >> x;

	int n = 1;
	int time = 1;
	while (n * (n + 1) / 2 < x) {
		++time;
		++n;
	}

	cout << time << "\n";

	return 0;

}

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

long long s;
long long ans=0;
int x[11]={0};

void solve(int n,int ten,long long now){
  if(x[n]!=0){
    now += (long long)x[n]*ten;
    solve(n-1,ten*10,now);
    solve(n-1,1,now);
  }
  else{
    //   cout << now << endl;
    ans += now;
  }
}

int main(){
  int i,j;

  cin >> s;
  for(i=0;i<10;i++){
    x[10-i] = int(s%10);
    s /=10;
  }
  solve(10,1,0);
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    int a,b,c,d;
    double e;
    cin >> a >>b;
    c = a/b;
    d = a%b;
    e = double(a)/double(b);
    printf("%d %d %10.6f",c,d,e);
}

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

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

	bool n = false, w = false, s = false, e = false;
	for (int i = 0;i < str.size();i++) {
		switch (str[i]) {
		case 'N':
			n = true;
			break;
		case 'W':
			w = true;
			break;
		case 'S':
			s = true;
			break;
		case 'E':
			e = true;
			break;
		}
	}
	if (((n&&s) || (!n && !s)) && ((w&&e) || (!w && !e))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        long num = long.Parse(Console.ReadLine());
        decimal percent=0.01m;
        long count=0;
        long now=100;
        while (true)
        {
    //            Console.WriteLine(now);
            if (now  >= num)
            {
                Console.WriteLine(count);
   //     Console.ReadLine();
                return;
            }
            count++;
            now+=(long)(now * percent);

        }

    }


    static int[] Convert(string[] v)
    {
        var temp = new int[v.Length];

        for (int i = 0; i < temp.Length; i++)
        {
            temp[i] = int.Parse(v[i]);
        }

        return temp;
    }




    static string[] GetLines()
    {
        return Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
    }


}

Measured memory_bytes: 27468
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

template <class T>
string sprint_arr(const vector<T> &arr) {
  stringstream ss;
  for (auto t : arr) {
    ss << t << " ";
  }
  return ss.str();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;

  int32_t n;
  cin >> n;
  map<int32_t, int64_t> sequences;
  vector<pair<int32_t, int32_t>> flowers(n);
  rep(i, n) {
    int32_t h;
    cin >> h;
    pair<int32_t, int32_t> &flower = flowers[i];
    flower.first = h;
  }
  rep(i, n) {
    int32_t a;
    cin >> a;
    pair<int32_t, int32_t> &flower = flowers[i];
    flower.second = a;
  }

  int64_t max_result = 0;
  rep(i, n) {
    auto current = sequences.lower_bound(flowers[i].first);
    int64_t current_result;
    if (current == sequences.begin()) {
      current_result = flowers[i].second;
    } else {
      current--;
      current_result = flowers[i].second + current->second;
    }
    max_result = max(max_result, current_result);
    sequences[flowers[i].first] = current_result;
    current = sequences.upper_bound(flowers[i].first);
    while (current != sequences.end() && current->second <= current_result) {
      sequences.erase(current);
      current = sequences.upper_bound(flowers[i].first);
    }
  }
  cout << max_result;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
using namespace std;
#define pi M_PI

int main(){
  int a = 0;
  string s;
  cin >> s;

  if(s.at(0) == '+'){
    a++;
  }
  else if(s.at(0) == '-'){
    a--;
  }

  if(s.at(1) == '+'){
    a++;
  }
  else if(s.at(1) == '-'){
    a--;
  }

  if(s.at(2) == '+'){
    a++;
  }
  else if(s.at(2) == '-'){
    a--;
  }

  if(s.at(3) == '+'){
    a++;
  }
  else if(s.at(3) == '-'){
    a--;
  }
  
  cout << a << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

        int a, b, c;
        int i, div_num = 0;

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

        if(a < 1 || a > 10000 || b < 1 || b > 10000 || c < 1 || c > 10000 || a > b) {
                return 1;
        }

        for(i = a; i <= b; i++) {
                if(c % i == 0) div_num++;
        }

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

        return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> nums(110);

  for (int i = 0; i < N; i++) cin >> nums.at(i);

  sort(nums.begin(), nums.end(), greater<int>());

  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++){
    if (i%2==0){
      alice += nums[i];
    }else{
      bob += nums[i];
    }
  }

  cout << alice - bob << endl;

}

Measured memory_bytes: 256
// Your code here!

import std.stdio,std.conv,std.string,std.algorithm,std.array,std.math;
void main(){
    auto s=readln().chomp().split().map!(to!int);
    int a=s[0],b=s[1],x=s[2];
    if(a<=x && x<=a+b)
        writeln("YES");
    else
        writeln("NO");
}

Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

N = INT()
S = input()
x = 0
ans = 0

for s in S:
    if s == "I":
        x += 1
    else:
        x -= 1
        
    ans = max(ans, x)
        
print(ans)

Measured memory_bytes: 61880
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define P pair<int, int>

int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
string S;
int A[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  N = S.length();
  A[0] = (S[0] == '1');
  rep(i, N-1) {
    A[i+1] = S[i]!=S[i+1];
  }
  int d = N;
  rep(i, N) {
    if (A[i]) d = min(d, max(i, N-i));
  }
  cout << d << "\n";
  return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  int wi[n];
  int vi[n];
  int ac = 0;
  for(int i = 0; i<n;i++){
    cin >> wi[i] >> vi[i];
    ac+= vi[i];
  }
  long long dp[n+1][ac+1];
  for(int i = 0; i<=n;i++){
    for(int j = 0; j<=ac;j++){
      dp[i][j] = 1000000000000;
    }
  }
  dp[0][0]  = 0;
  for(int i = 1; i<=n;i++){
    for(int j = 0; j<=ac;j++){
      if(j>=vi[i-1]){
	dp[i][j] = min(dp[i-1][j],dp[i-1][j-vi[i-1]]+wi[i-1]);
      }else{
	dp[i][j] = dp[i-1][j];
      }
    }
  }
  int ans = 0;
  for(int i = 0; i<=ac;i++){
    if(dp[n][i]<=w){
      ans = max(ans,i);
    }
  }
  cout << ans <<'\n';
  return 0;
}


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

public class Program
{
	public static void Main()
	{
		var NM = Console.ReadLine().Split().Select(int.Parse);
		int N = NM.First(), M = NM.Last();
		var A = new string[N];
		var B = new string[M];
		for (int i = 0; i < N; i++)
		{
			A[i] = Console.ReadLine();
		}
		for (int i = 0; i < M; i++)
		{
			B[i] = Console.ReadLine();
		}
		for (int y = 0; y + M <= N; y++)
		{
			for (int x = 0; x + M <= N; x++)
			{
				var flag = true;
				for (int ly = 0; ly < M; ly++)
				{
					for (int lx = 0; lx < M; lx++)
					{
						flag &= A[y + ly][x + lx] == B[ly][lx];
					}
				}
				if (flag)
				{
					Console.WriteLine("Yes");
					return;
				}
			}
		}
		Console.WriteLine("No");
	}
}

Measured memory_bytes: 13396
text_ = input()

if text_ != text_[::-1]:
    print('No')
elif text_[:((len(text_)-1) // 2)] != text_[:((len(text_)-1) // 2)][::-1]:
    print('No')
elif text_[((len(text_)+3)//2)-1:] != text_[((len(text_)+3)//2)-1:][::-1]:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc093/tasks/abc093_a

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  string s, r;

  cin >> s;

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

  r = "abc" == s ? "Yes" : "No";

  cout << r << '\n';

  return 0;
}


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

int main() {
  int X,ans;
  bool A=true;
  cin >> X;
  for(int i=0;i<10000;i++){
    for(int j=2;j<X;j++){
      if(X%j==0){
        A=false;
        break;
      }
    }
    if(A==true){
      ans=X;
      break;
    }
    X++;
    A=true;
  }
  cout << ans << endl;
}

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

using namespace std;
char grid[1001][1001];
const int M = 1e9 + 7;
int main()
{
    int n , m ; cin>>n>>m;
    for(int i = 0; i < n; ++i)cin>>grid[i];
    vector<vector<int>> dp(n , vector<int>(m));
    dp[0][0] = 1;
    for(int i = 0 ; i < n; ++i){
        for(int j = 0 ; j < m; ++j){
            for(int r : {i , i + 1}){
                int c = j;
                if(r == i)c = j + 1;
                if(r < n && c < m && grid[r][c] == '.'){
                    dp[r][c] = (dp[r][c] + dp[i][j]) % M;
                }
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}


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

using namespace std;

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

const int mo = 1e9 + 7;
int dp[100010][10][13];
string s;

signed main()
{
	cin >> s;

	int n = s.size();

	if (s[n-1] == '?') {
		rep(i, 10) dp[n-1][i][i] = 1;
	} else {
		int d = s[n-1] - '0';
		dp[n-1][d][d] = 1;
	}

	int m = 10;
	for (int i = n-2; i >= 0; --i){
		if (s[i] != '?') {
			int d = s[i] - '0';
			rep(j, 10) {
				rep(k, 13) {
					dp[i][d][(d*m + k)% 13] += dp[i+1][j][k];
					dp[i][d][(d*m + k)% 13] %= mo;
				}
			}
		} else {
			rep(d, 10) {
				rep(j, 10) {
					rep(k, 13) {
						dp[i][d][(d*m + k)% 13] += dp[i+1][j][k];
						dp[i][d][(d*m + k)% 13] %= mo;
					}
				}
			}
		}

		m *= 10;
		m %= 13;
	}

	int ans = 0;

	rep(i, 10) {
		ans += dp[0][i][5];
		ans %= mo;
	}

	cout << ans << endl;
}


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

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

    for(int i = 0; i < w+2; i++)  cout << "#";
    cout << endl;

    for(int i = 0; i < h; i++){
        cin >> s;
        cout << "#" << s << "#" << endl;
    }

    for(int i = 0; i < w+2; i++)  cout << "#";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
//-----------------------------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
//-----------------------------------------------------------------------------

int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cinsc;
}

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

int main(){
   // in_o();
    int n;string s;
    cin>>n>>s;
    int ans=1;
    FOR(i,0,n-1){
        if(s[i]!=s[i+1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

bool block[2'000][2'000];
int u[2'000][2'000], d[2'000][2'000], l[2'000][2'000], r[2'000][2'000];

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
        {
            block[i][j] = (s[j] == '#');
        }
    }

    for (int i = 0; i < h; i++)
    {
        l[i][0] = 0;
        for (int j = 1; j < w; j++)
        {
            if (block[i][j - 1])
            {
                l[i][j] = 0;
            }
            else
            {
                l[i][j] = l[i][j - 1] + 1;
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        r[i][w - 1] = 0;
        for (int j = w - 2; j >= 0; j--)
        {
            if (block[i][j + 1])
            {
                r[i][j] = 0;
            }
            else
            {
                r[i][j] = r[i][j + 1] + 1;
            }
        }
    }

    for (int j = 0; j < w; j++)
    {
        u[0][j] = 0;
        for (int i = 1; i < h; i++)
        {
            if (block[i - 1][j])
            {
                u[i][j] = 0;
            }
            else
            {
                u[i][j] = u[i - 1][j] + 1;
            }
        }
    }
    for (int j = 0; j < w; j++)
    {
        d[h - 1][j] = 0;
        for (int i = h - 2; i >= 0; i--)
        {
            if (block[i + 1][j])
            {
                d[i][j] = 0;
            }
            else
            {
                d[i][j] = d[i + 1][j] + 1;
            }
        }
    }

    int m = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            int score = u[i][j] + d[i][j] + l[i][j] + r[i][j] + 1;
            int sc = (block[i][j] ? 0 : score);
            m = max(sc, m);
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 66688
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	K := nextInt()
	sum := 0
	for i := 1; i <= K; i++ {
		for j := 1; j <= K; j++ {
			for k := 1; k <= K; k++ {
				sum += gcd((gcd(i, j)), k)
			}
		}
	}
	fmt.Println(sum)
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}

func gcd(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}


Measured memory_bytes: 1772
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b;
  cin >> a >> b;
  if (a == 1) a = 100;
  if (b == 1) b = 100;
  if (a > b) {
    cout << "Alice" << endl;
  } else if (a < b) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

signed main(){
  int r,d,x;
  cin>>r>>d>>x;
  for(int i=0;i<10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]


n, m = na()
print("Yes" if n==m else "No")

Measured memory_bytes: 3064
const = 5 * (10 ** 5)
s = gets.chop
k = gets.chop.to_i

num_chars = s.chars.map(&:to_i)

selected = 0
current_number_of_char = 0
i = 0
found = 0

while found == 0 && i <= num_chars.length - 1
	current_number_of_char += num_chars[i] ** const
	
	if k <=  current_number_of_char
		selected = num_chars[i]
		found = 1
	end
	
	i += 1
end

puts selected

Measured memory_bytes: 2720