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

const int dx[] = {0, 0, 1, -1}, dy[] = {-1, 1, 0, 0};

int h, w;
int n;
int lx[1010], ly[1010], rx[1010], ry[1010];
vector<int> x, y;

bool d[2020][2020];

void dfs(int i, int j)
{
  if (i < 0 || j < 0 || h < i || w < j) return;
  if (d[i][j]) return;
  d[i][j] = true;

  for (int k = 0; k < 4; k++){
    dfs(i + dy[k], j + dx[k]);
  }
}

int main()
{
  while (cin >> h >> w, h){
    x = vector<int>();
    y = vector<int>();
    memset(d, false, sizeof(d));
    
    cin >> n;

    for (int i = 0; i < n; i++){
      cin >> lx[i] >> ly[i] >> rx[i] >> ry[i];
      x.push_back(lx[i]); x.push_back(rx[i]);
      y.push_back(ly[i]); y.push_back(ry[i]);
    }
    x.push_back(0); x.push_back(w);
    y.push_back(0); y.push_back(h);

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    y.erase(unique(y.begin(), y.end()), y.end());

    for (int i = y.size() - 2; i >= 0; i--){
      for (int j = x.size() - 2; j >= 0; j--){
        bool f = false;
        for (int k = 0; k < n; k++){
          if (lx[k] <= x[j] && x[j + 1] <= rx[k] && 
              ly[k] <= y[i] && y[i + 1] <= ry[k]) f = true;
        }
        d[i][j] = f;
      }
    }

    h = y.size() - 2;
    w = x.size() - 2;

    int ans = 0;
    for (int i = 0; i < y.size() - 1; i++){
      for (int j = 0; j < x.size() - 1; j++){
        if (d[i][j]) continue;
        dfs(i, j);
        ans++;
      }
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 11808
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;

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

int i;
cin >> i;
string ans;
if(1000<=i)cout << "ABD" << endl;
else cout << "ABC" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    int maxl = 0;
    int minr = Inf;
    cin >> n >> m;
    int l[m], r[m];
    rep (i, m) {
      cin >> l[i] >> r[i];
      maxl = max(maxl, l[i]);
      minr = min(minr, r[i]);
    }
    int ans = minr - maxl + 1;
    ans = max(ans, 0);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> v(n);rep(i,0,n)cin>>v[i];

  ll ans=0,sum=0;
  rep(i,0,n){
    ans+=sum*v[i]%mod;
    ans%=mod;
    sum+=v[i];
    sum%=mod;
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
vector<int> t_sort(vector<vector<int>> &g,int &c){
    vector<int> res,cnt(g.size(),0);
    queue<int> q;
    rep(i,g.size()){
        for (int e:g[i]){
            cnt[e]++;
        }
    }
    rep(i,g.size()){
        if (cnt[i] == 0) q.push(i);
    }
    while(!q.empty()){
        c++;
        queue<int> p;
        while(!q.empty()){
            p.push(q.front());
            q.pop();
        }
        while(!p.empty()){
            int v = p.front();p.pop();
            res.push_back(v);
            for (int u:g[v]){
                cnt[u]--;
                if (cnt[u] == 0){
                    q.push(u);
                }
            }
        }
    }
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> match(n,vector<int>(n-1)),p(n,vector<int>(n,0));
    int c = 0;
    vector<vector<int>> g(n*(n-1)/2);
    rep(i,n){
        rep(j,n){
            if (i == j) continue;
            if (i < j){
                p[i][j] = c;
                c++;
            }
            else{
                p[i][j] = p[j][i];
            }
        }
    }
    //rep(i,n) array_output(all(p[i]));
    rep(i,n){
        rep(j,n-1){
            cin >> match[i][j];
            match[i][j] -= 1;
        }
    }
    rep(i,n){
        rep(j,n-2){
            g[p[i][match[i][j]]].push_back(p[i][match[i][j+1]]);
        }
    }
    int k = 0;
    vector<int> t = t_sort(g,k);
    if (t.size() < n*(n-1)/2){
        PRINT(-1);
    }
    else PRINT(k);
}


Measured memory_bytes: 40944
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
#define pb                emplace_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (ll)((x).size())
#define ff                first
#define ss                second
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define isBitset(S,i)     ((S>>i)&1)
#define print(x) 		  for(auto it:x) cout<<it<<" "; cout<<"\n"; 
#define MOD 1000000007
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}
void solve()
{
	ll d,t,s;cin>>d>>t>>s;
	ld k=s;
	if(ceil(d/k)<=t)
		cout<<"Yes";
	else
		cout<<"No";
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);   
        solve();
    return 0;
}

Measured memory_bytes: 3588
import functools
import math
import sys

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

array = list(map(int,input().split()))
N = array[0]
X = array[1]
array = list(map(int,input().split()))
if len(array) == 1:
  print(abs(array[0] - X))
  sys.exit()
array.append(X)
array.sort()
A = array[:array.index(X) + 1]
B = array[array.index(X):]
C = []
for i in range(1,len(A)):
  C.append(A[i] - A[i - 1])
for i in range(1,len(B)):
  C.append(B[i] - B[i - 1])

a = gcd(C[0],C[1])
for i in C:
  a = gcd(a,i)
print(a)



Measured memory_bytes: 14596
N,M,K=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
SA=[0 for i in range(N+1)]
SB=[0 for i in range(M+1)]
for i in range(N):
    SA[i+1]=A[i]+SA[i]
for i in range(M):
    SB[i+1]=B[i]+SB[i]
ans=0
for i in range(N+1):
    if SA[i]>K:
        break
    low=0
    high=M+1
    while(high-low>1):
        mid=(low+high)//2
        #SA[i]+SB[low]<=K<SA[i]+SB[high]
        if SA[i]+SB[mid]<=K:
            low=mid
        else:
            high=mid
    ans=max(ans,i+low)
print(ans)


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

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> LOC = new ArrayDeque<Integer>();
		Deque<Info> POOL = new ArrayDeque<Info>();

		int tmp_S,tmp_start,tmp_end,sum = 0;

		try {

			char array[] = br.readLine().toCharArray();
			for(int i = 0; i < array.length; i++){
				if(array[i] == '\\'){
					LOC.addFirst(i);
				}else if(array[i] == '/'){

					if(LOC.isEmpty())continue;

					tmp_start = LOC.getFirst();
					LOC.removeFirst();
					tmp_end = i;

					tmp_S = tmp_end-tmp_start;
					sum += tmp_S;

					while(POOL.isEmpty() == false && POOL.getFirst().getStart() > tmp_start && POOL.getFirst().getEnd() < tmp_end){
						tmp_S += POOL.getFirst().getS();
						POOL.removeFirst();
					}

					POOL.addFirst(new Info(tmp_start,tmp_end,tmp_S));

				}else{ //array[i] == _
					//Do nothing
				}
			}

			System.out.println(sum);


			StringBuilder ans = new StringBuilder();

			ans.append(Integer.toString(POOL.size()));

			while(!POOL.isEmpty()){
				ans.append(" ").append(Integer.toString(POOL.getLast().getS()));
				POOL.removeLast();
			}

			System.out.println(ans.toString());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Info{
	private int start;
	private int end;
	private int S;

	Info(int start,int end,int S){
		this.start = start;
		this.end = end;
		this.S = S;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getEnd() {
		return end;
	}

	public void setEnd(int end) {
		this.end = end;
	}

	public int getS() {
		return S;
	}

	public void setS(int s) {
		S = s;
	}
}





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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int i,n,k;
    vector<int>vec,vec2;
    sf(n);
    rep0(i,n)
    {
        sf(k);
        vec.pb(k);
    }
    rep0(i,n)
    {
        sf(k);
        vec2.pb(k);
    }
    int x=0,y=0;
    rep0(i,n)
    {
        if(vec[i]>vec2[i])
        {
            x+=vec[i];
            y+=vec2[i];
        }
    }
    cout<<x-y;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int a;
    cin >> a;
    cout << "ABC" << a;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner
import scala.math._

object Main extends App {

  val sc = new Scanner(System.in)

  val N = sc.nextInt()

  var list = List.fill(N)(sc.nextInt())
  var cnt = 0

  while (list.forall(_ % 2==0)){
    cnt+=1
    list = list.map(_ / 2)
  }
  println(cnt)
}



Measured memory_bytes: 27720
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, K, RSP[3], res, DP[100000][3];
string T;

char c[3] = { 'r','s','p' };


int main() {
	cin >> N >> K >> RSP[0] >> RSP[1] >> RSP[2] >> T;
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < 3; j++) {
			if (T[i] == c[j]) {
				DP[i][(j + 2) % 3] = RSP[(j + 2) % 3];
			}
		}
		int j;
		for (j = i + K; j < N; j += K) {
			for (int k = 0; k < 3; k++) {
				DP[j][k] = max(DP[j - K][(k + 1) % 3], DP[j - K][(k + 2) % 3]);
			}
			for (int k = 0; k < 3; k++) {
				if (T[j] == c[k]) {
					DP[j][(k + 2) % 3] += RSP[(k + 2) % 3];
				}
			}
		}
		j -= K;
		res += max({ DP[j][0],DP[j][1],DP[j][2] });
	}
	cout << res << endl;
}

Measured memory_bytes: 1664
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <functional>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 100000000
template<class T, class C> void chmax(T& a, C b) { a>b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a<b ? : a = b; }
vector<long long>p(100005);
vector<long long>a(100005);
vector<long long>b(100005);
vector<long long>c(100005);
vector<long long>imos(100005);
long long int sum = 0;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n-1; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0; i < m - 1; i++) {
		if (p[i] > p[i + 1]) {
			imos[p[i+1]-1] += 1;
			imos[p[i]-1] -= 1;
		}
		else {
			imos[p[i]-1] += 1;
			imos[p[i+1]-1] -= 1;
		}
	}
	for (int i = 1; i < n - 1; i++) {
		imos[i] += imos[i - 1];
		//cout << imos[i] << " ";
	}
	for (int i = 0; i < n - 1; i++) {
		sum += min(imos[i] * a[i], imos[i] * b[i] + c[i]);
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

#ifdef RED
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = (int)1e6 + 5;

string s;

int main() {
#ifdef RED
  freopen("a.in", "r", stdin);
#endif
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  if (s == "Sunny")
    cout << "Cloudy\n";
  else if (s == "Cloudy")
    cout << "Rainy\n";
  else
    cout << "Sunny\n";
  return 0;
}


Measured memory_bytes: 256
def case_k1(n):
    digit = len(str(n))
    if digit ==1:
        return n
    else:
        return (n//(10**(digit-1))+(digit-1)*9)

def case_k2(n):
    digit = len(str(n))
    if digit == 1:
        return 0
    elif digit ==2:
        return (n//10-1)*9+n%10
    else:
        sum = 0
        for i in range(1,digit-1):
            sum += i*81
        q = n//(10**(digit-1))
        r = n-q*10**(digit-1)
        r_digit = len(str(r))
        sum += (q-1)*(case_k1(10**(digit-1)-1)) + case_k1(r)
        return sum

def case_k3(n):
    digit = len(str(n))
    if digit <3:
        return 0
    else:
        sum = 0
        for i in range(2,digit-1):
            sum += 9*case_k2(10**(i)-1)
        q = n//(10**(digit-1))
        r = n-q*10**(digit-1)
        sum += (q-1)*(case_k2(10**(digit-1)-1)) + case_k2(r)
        return sum

N = input()
K = int(input())
n = int(N)
if K ==1:
    print(case_k1(n))
elif K ==2:
    print(case_k2(n))
else:
    print(case_k3(n))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using namespace std;
// cout << fixed << setprecision(10）<<  << endl;

int main() {
    string s; cin >> s;
    cout << s;
    if (*s.rbegin() == 's') cout << "es" << endl;
    else cout << "s" << endl;
}

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

using namespace std;

int n,res,a[100000];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    int i=1;
    while (i<=n) {
        int j=i;
        while (j+1<=n && a[j+1]==a[i]) j++;
        int s = j-i+1;
        res += s/2;
        i = j+1;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
        ll a,b,c; cin >> a >> b >> c;
        cout << min( a+b, min(a+c, b+c)) << endl;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  auto cnt = 0;
  rep(i, 6) {
    if (s[i] == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

bool f(vector<int> &a) {
  int N	= a.size();
  if(N <= 1) return true;
  for(int i = 1; i < N; i++) {
    if(a[i] - 1	>= a[i-1]) a[i]--;
    if(a[i] < a[i-1]) return false;
  }
  return true;
}


int main() {
  int N; cin>>N;
  vector<int> a(N);
  REP(i,N) cin>>a[i];
  bool ans = f(a);
  YesNo(ans);
  return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; string S; cin >> N >> S;
  vector<int> wnum(N), bnum(N);

  bnum[0] = (S[0] == '#');
  wnum[N-1] = (S[N-1] == '.');

  for (int i = 1; i < N; ++i) {
    bnum[i] = bnum[i-1];
    if (S[i] == '#') bnum[i]++;
  }

  for (int i = N-2; i >= 0; --i) {
    wnum[i] = wnum[i+1];
    if (S[i] == '.') wnum[i]++;
  }

  int ans = wnum[0];
  ans = min(ans, bnum[N-1]);

  for (int i = 0; i < N-1; ++i) {
    ans = min(ans, bnum[i]+wnum[i+1]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 2180
import sys
input = sys.stdin.readline

from heapq import heappop, heappush

def main():
  n, c = map(int, input().split())
  stc = []
  for _ in range(n):
    stc.append(tuple(map(int, input().split())))
  stc = list(sorted(stc, key=lambda x: (x[2], x[0])))
  restc = []
  prev = stc[0]
  for _stc in stc[1:]:
    if prev[2] == _stc[2] and prev[1] == _stc[0]:
      prev = (prev[0], _stc[1], prev[2])
    else:
      restc.append(prev)
      prev = _stc
  restc.append(prev)

  ans = 0
  th = []
  for _stc in sorted(restc):
    if not th:
      heappush(th, _stc[1])
      if ans == 0:
        ans = 1
    else:
      _th = heappop(th)
      if _th < _stc[0]:
        heappush(th, _stc[1])
      else:
        heappush(th, _th)
        heappush(th, _stc[1])
        ans = max(ans, len(th))
  print(ans)


if __name__ == '__main__':
  main()


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

int n;
vector<int> a;

int main(){
    cin >> n;
    for(int i = 0;i <= n;i++){
        a.push_back(0);
    }
    /**/
    int m = 100;
    /*
    while(6*m*m < n){
        m++;
    }
    m++;
    cout << m << endl;
    */
    /**/
    for(int x = 1;x <= m;x++){
        for(int y = 1;y <= m;y++){
            for(int z = 1;z <= m;z++){
                int f = x*x + y*y + z*z + x*y + x*z + z*y;
                //cout << f << endl;
                if(f <= n) a[f]++;
            }
        }
    }

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

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

bool win(string s,char c){
	for(int y=0;y<9;y+=3)
		if(s[y]==c&&s[y+1]==c&&s[y+2]==c)return true;
	for(int x=0;x<3;x++)
		if(s[x]==c&&s[x+3]==c&&s[x+6]==c)return true;
	if(s[0]==c&&s[4]==c&&s[8]==c)return true;
	if(s[2]==c&&s[4]==c&&s[6]==c)return true;
	return false;
}
int main(){
	string s;
	while(cin>>s){
		cout<<(win(s,'o')?'o':win(s,'x')?'x':'d')<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define inf 1000000007;
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;
}

int n, a[200000], ans = 1000000000000000010, ta = 0, mu = 0;

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		ta += a[i];
	}
	rep(i, n - 1) {
		mu += a[i];
		if (ans > abs((ta - mu) - mu)) {
			ans = abs((ta - mu) - mu);
		}
	}
	cout << ans << endl;
	getchar(); getchar();
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
#include<queue>
#include<string.h>
using namespace std;
int main()
{
   int x,a,b,sum=0;
   cin>>x>>a>>b;
   if(a+b<=x){
      cout<<(x-a)%b<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl

const ll INF=1e9+7;
const ll N = 100002;
ll n,c,k,ans=0;
vector<ll> t;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>c>>k;
	FOR(i,0,n){
		ll p;
		cin>>p;
		t.pb(p);
	}
	SORT(t);
	ll nin=1;
	ll ti=0;
	ans=1;
	FOR(i,1,t.size()){
		nin++;
		if(nin>c){
			nin=1;
			ti=0;
			ans++;
			continue;
		}
		ti+=t[i]-t[i-1];
		if(ti>k){
			nin=1;
			ti=0;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    //入力
    string S;
    cin>>S;
    
    int SL=S.length();
    
    int time[3];
    string timeS;
    
    int k=0;
    //処理
    for(int i=0;i<SL;i++){
        //cout<<S[i];
        if(S[i]=='/'){
            //time[k]=int(timeS);
            time[k] = atoi(timeS.c_str());
            k++;
            timeS="";
        }
        else{
            timeS=timeS+S[i];
        }
    }
    
    if(time[0]>2019){
        cout<<"TBD"<<endl;
    }
    else if(time[0]==2019&&time[1]>4){
        cout<<"TBD"<<endl;
    }
    else if(time[0]==2019&&time[1]==4&&time[2]>30){
        cout<<"TBD"<<endl;
    }
    else{
        cout<<"Heisei"<<endl;
    }
    
    //出力
    //cout<<S<<endl;
    //cout<<time[1]<<endl;
    
}


Measured memory_bytes: 256
import heapq
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input


class MinCostFlow:
    class Edge:
        def __init__(self, to, cap, rev, cost):
            self.to, self.cap, self.rev, self.cost = to, cap, rev, cost

    def __init__(self, V):
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, fr, to, cap, cost):
        self.E[fr].append(self.Edge(to, cap, len(self.E[to]), cost))
        self.E[to].append(self.Edge(fr, 0, len(self.E[fr])-1, -cost))

    def run(self, source, sink, f, INF=10**5):
        res = 0
        h, prevv, preve = [0] * self.V, [0] * self.V, [0] * self.V
        while (f > 0):
            pque = []
            dist = [INF] * self.V
            dist[source] = 0
            heapq.heappush(pque, (0, source))
            while pque:
                cost, v = heapq.heappop(pque)
                cost = -cost
                if dist[v] < cost:
                    continue
                for i, e in enumerate(self.E[v]):
                    if e.cap > 0 and dist[v] - h[e.to] < dist[e.to] - e.cost - h[v]:
                        dist[e.to] = dist[v] + e.cost + h[v] - h[e.to]
                        prevv[e.to], preve[e.to] = v, i
                        heapq.heappush(pque, (-dist[e.to], e.to))
            if dist[sink] == INF:
                return -1
            for v in range(self.V):
                h[v] += dist[v]

            d, v = f, sink
            while v != source:
                d = min(d, self.E[prevv[v]][preve[v]].cap)
                v = prevv[v]
            f -= d
            res += d * h[sink]
            v = sink
            while v != source:
                self.E[prevv[v]][preve[v]].cap -= d
                self.E[v][self.E[prevv[v]][preve[v]].rev].cap += d
                v = prevv[v]
        return res


while True:
    N = int(input())
    if not N:
        break
    V = 366
    mcf = MinCostFlow(V)
    for i in range(V - 1):
        mcf.add_edge(i, i + 1, 2, 0)
    for _ in range(N):
        s, t, c = map(int, input().split())
        mcf.add_edge(s - 1, t, 1, -c)
    print(-mcf.run(0, V - 1, 2, 10 ** 9))

Measured memory_bytes: 7604
from queue import deque
# import sys
# input = lambda : sys.stdin.readline().rstrip()

k = int(input())
q = deque()
for i in range(1,10):
    q.appendleft(i)
for _ in range(k):
    num = q.pop()
    n = num % 10
    if n!=0:
        q.appendleft(num*10+n-1)
    q.appendleft(num*10+n)
    if n!=9:
        q.appendleft(num*10+n+1)
print(num)

Measured memory_bytes: 40940
n, k = gets.chomp.split(' ').map(&:to_i)

hash = Hash.new(0)
k.times do
  d = gets
  arr = gets.chomp.split(' ').map(&:to_i)
  arr.each do |i|
    hash[i.to_s] += 1
  end
end

treat_count = 0
n.times do |i|
  if hash[(i+1).to_s] == 0
    treat_count += 1
  end
end

puts treat_count

Measured memory_bytes: 14288
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

bool divide(int p, std::vector<int> a) {
  for (int i = (int)a.size() - 1; i - p + 1 > 0; -- i) {
    a[i - p + 1] += a[i];
  }
  for (int i = std::min(p - 1, (int)a.size() - 1); i >= 0; -- i)
    if (a[i] % p)
      return false;
  return true;
}

bool is_prime(int p) {
  for (int i = 2; i * i <= p; ++ i)
    if (p % i == 0)
      return false;
  return true;
}

int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> a(n + 1);
  int g = 0;
  for (int i = n; i >= 0; -- i) {
    scanf("%d", &a[i]);
    g = gcd(g, std::abs(a[i]));
  }
  std::vector<int> result;
  for (int p = 2; p <= n; ++ p) if (is_prime(p)) {
    if (divide(p, a))
      result.emplace_back(p);
  }
  for (int p = 2; p * p <= g; ++ p) if (g % p == 0) {
    while (g % p == 0) g /= p;
    if (divide(p, a))
      result.emplace_back(p);
  }
  if (g > 1 && divide(g, a))
    result.emplace_back(g);
  std::sort(result.begin(), result.end());
  result.erase(std::unique(result.begin(), result.end()), result.end());
  for (auto t : result)
    printf("%d\n", t);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100002;

int n, m;
string s, t;
vector <int> nex[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s >> t;
    n = s.size();
    m = t.size();
    vector <int> cur(26, n);
    for(int i = n - 1 ; i >= 0 ; i--){
        nex[i] = cur;
        cur[s[i] - 'a'] = i;
    }
    int ind = -1;
    ll ans = 0;
    for(int i = 0 ; i < m ; i++){
        int to = -1;
        if(ind == -1) to = cur[t[i] - 'a'];
        else to = nex[ind][t[i] - 'a'];
        if(ind == -1 && to == n) finish(-1);
        ans += to - ind;
        ind = to;
        if(to == n){
            ans--;
            ind = -1;
            i--;
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int a, b;
    while (cin>>a>>b){
        int c=a+b,count=1;
        while (c >= 10) {
            c /= 10;
            count++;
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cmath>
# include <string>
# include <cstring>
# include <iomanip>
# include <functional>
# include <numeric>
# include <map>
# include <cstdlib>
# include <queue>
# include <cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
const int N=500005;
inline int lowbit(int x) {return x&(-x);}
int n;
char s[N];
int k[N][30];
inline void update (int x,int y,int res)
{
    for(int i=x;i<=n;i+=lowbit(i))
        k[i][res]+=y;
}
inline int getsum (int x,int res)
{
    int ans=0;
    for(int i=x;i;i-=lowbit(i))
        ans+=k[i][res];
    return ans;
}
int main ()
{
	n=read (n);
	scanf ("%s",s+1);
	for (int i=1;i<=n;i++)
		update (i,1,s[i]-'a'+1);
	int t=read (t);
	while (t--)
	{
		int opt=read (opt);
		if (opt==1)
		{
			int x;char c;
			scanf ("%d %c",&x,&c);
			update (x,-1,s[x]-'a'+1);
			s[x]=c;
			update (x,1,s[x]-'a'+1);
		}
		else
		{
			int l=read (l),r=read (r);
			int tot=0;
			for (int i=1;i<=26;i++)
			{
				int x=getsum (r,i);
				int y=getsum (l-1,i);
				if (x-y>0)
					tot++;
			}
			printf ("%d\n",tot);
		}
	} 
	return 0;
}

Measured memory_bytes: 59392
#include <iostream>
//#include <math.h>
#include <set>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    int n;
    int cnt=0;
    string s;
    cin >> n>>s;
    for(int i=0;i<n-2;i++){
      if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
    }
    cout << cnt<<endl;
    
    return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
bool R(){return true;}
template<typename T, typename ... Args>
bool R(T & x, Args & ... args){return cin >> x && R(args...);}
void init_io(){ios::sync_with_stdio(false);cin.tie(0);}

#define PB push_back
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 4000000000000000007LL

string s, t;

void solve ()
{
  R(s, t);
  int res = 0;
  FOR(i, 0, s.length()) if (s[i] != t[i]) ++res;
  printf("%d\n", res);
}

int main ()
{
  init_io();
  int T = 1;
  //R(T);
  while (T--) solve();
  return 0;
}


Measured memory_bytes: 3916
#include <stdio.h>

int main(){

    char N[3];
    scanf("%s", N);
 
    if(N[0] == '7'){
     printf("Yes");
    }else if(N[1] == '7'){
        printf("Yes");
    }else if(N[2] == '7'){
     printf("Yes");
    }else{
     printf("No");
    }

 return 0;
}

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

//int sieve[9999999];

int main()
{
    ///BISMILLAHIR RAHMANIR RAHIM
   int x,y;
   cin>>x>>y;
   if(y>(4*x)||y<(2*x))
    cout<<"No"<<endl;
   else if(y%2 !=0){
    cout<<"No"<<endl;
   }
   else cout<<"Yes"<<endl;
    /// A L H A M D U L I L L A H
}


Measured memory_bytes: 3620
# Date [ 2020-08-29 21:00:08 ]
# Problem [ a.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    d, t, s = read_ints()
    if s * t >= d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9224
#include <cstdio>
using namespace std;

char m1[60][60],m2[60][60];
int n,m;

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)scanf("%s",m1[i]);
	for(int i=0;i<m;i++)scanf("%s",m2[i]);
	for(int i=0;i<=n-m;i++){
		for(int j=0;j<=n-m;j++){
			bool ok=1;
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(m1[i+k][j+l]!=m2[k][l])ok=0;
				}
			}
			if(ok) return puts("Yes"),0;
		}
	}
	return puts("No"),0;
}

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
  int a, b;
  cin >> a >> b;
  cout << (a+b) / 2 << endl;
  return 0;
}

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

int main() {
  for (int a, b = 0; std::cin >> a >> b,
      a != 0 || b != 0;) {
    if (a < b) std::cout << a << " " << b << std::endl;
    else std::cout << b << " " << a << std::endl;
  }

  return 0;
}


Measured memory_bytes: 2996
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(Args...)
#endif
using ll = long long;
using namespace __gnu_pbds;
using namespace std;
template<class T>
using indexed_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

void shit() {
    ll n, a, b; cin >> n >> a >> b;
    if(a > b) {
		cout << 0 << endl;
		return;
	}
	if(n == 1 and a != b) {
		cout << 0 << endl;
		return;
	}
	if(n == 1) {
		cout << 1 << endl;
		return;
	}
	if(a == b) {
		cout << 1 << endl;
		return;
	}
	cout << (n - 2)*(b - a) + 1 << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		shit();
	return 0;
}


Measured memory_bytes: 3596
#pragma GCC optimize("O2")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1516
def main():
    N = int(input())

    max_left = [0] * N
    max_right = [0] * N

    ary = []

    for i in range(N):
        v = int(input())
        ary.append(v)

    for i in range(N - 1):
        max_left[i+1] = max(max_left[i], ary[i])

    for i in range(N - 1, 0, -1):
        max_right[i-1] = max(max_right[i], ary[i])

    for i in range(N):
        v = max(max_left[i], max_right[i])
        print(v)


main()


Measured memory_bytes: 15656
#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(){
    double x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    printf("%.8f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}



Measured memory_bytes: 3208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		// solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 2;
	}

	int W;
	int H;

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		if (cnt < 1) {
			W = Integer.parseInt(strArr[0]);
			H = Integer.parseInt(strArr[1]);
		} else {
			int w = Integer.parseInt(strArr[0]);
			int h = Integer.parseInt(strArr[1]);
			int ans = (W - w) * (H - h);
			System.out.println(ans);
		}
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


int main() {
	cout << fixed << setprecision(18);
	string str;
	getline(cin,str);
	
	while(str!="."){
		stack<char>ch;
		for(int i=0;i<str.length();i++){
			if(str[i]=='('){ch.push('(');}
			if(str[i]=='['){ch.push('[');}
			if(str[i]==')'){
				if(ch.empty()){cout<<"no"<<endl;goto next;}
				if(ch.top()=='('){ch.pop();}
				else{cout<<"no"<<endl;goto next;}
			}
			if(str[i]==']'){
				if(ch.empty()){cout<<"no"<<endl;goto next;}
				if(ch.top()=='['){ch.pop();}
				else{cout<<"no"<<endl;goto next;}
			}
		}
		if(ch.empty()){cout<<"yes"<<endl;}
		else{cout<<"no"<<endl;}
		next:
		getline(cin,str);
	}
} 


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

string S;

vi solve() {
    vi res(S.size());
    int l = 0, m = 0, r = 0;
    while (l < S.size()) {
        while (S[m] == 'R') m++;
        r = m;
        while (S[r] == 'L') r++;
        res[m-1] = res[m] = (r-l)/2;
        if ((r-l)%2) {
            int k = ((m&1) ^ (r&1)) ? m : m-1;
            res[k]++;
        }
        l = m = r;
    }
    return res;
}

int main() {
    cin >> S;
    FORE (x, solve()) {
        cout << x << endl;
    }
}

Measured memory_bytes: 1536