akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    string S;
    ll Q;
    cin >> S >> Q;
    bool flag = true;
    string a, b;
    while (Q--) {
        ll t;
        cin >> t;
        if (t == 1) {
            flag = not flag;
        } else {
            char f, c;
            cin >> f >> c;
            if (f == '1' and flag or f == '2' and not flag) {
                a.push_back(c);
            } else {
                b.push_back(c);
            }
        }
    }

    reverse(a.begin(), a.end());

    string ans = a + S + b;

    // cout << a << " " << S << " " << b << "\n";
    
    if (!flag) reverse(ans.begin(), ans.end());

    cout << ans << endl;
    
}

Measured memory_bytes: 1300
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	double sum = 0;
	for (int i = 0; i < N; i++) {
		double x;
		string u;
		cin >> x >> u;
		if (u == "JPY") {
			sum += x;
		}
		else {
			sum += x * 380000.0;
		}
	}
	printf("%.15lf\n", sum);
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
ll GCD(ll n, ll m) {
    return m ? GCD(m, n % m) : n;
}
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    ll g = GCD(n, m);

    bool flag = true;
    for (ll i = 0; i < g; ++i) {
        if (s[i * n / g] != t[i * m / g]){
            flag = false;
            break;
        }
    }

    ll res = n / g * m;
    if (flag == false){
        res = -1;
    }
    cout << res << endl;

    return 0;
}


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

int main(){
  int a,b;
  //string a, b, c, d;
  cin >> a >> b;// >> x;
  //cin >> s;
  if(a<=b)cout << a << endl;
  else cout << a-1 << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first;
#define S second;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i <= b; i++)
#define SQ(a) (a)*(a);

const int INF = 1e9 + 5;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n ;
    scanf("%d",&n);
    vector<int> h(n);

    for(int&x : h){
        scanf("%d",&x);
    }

    vector<int> dp(n,INF);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j : {i + 1,i + 2}) {
            dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
        }
    }

    printf("%d",dp[n - 1]);

    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main{
    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);

        int t = Integer.parseInt(scan.next());

        Integer w[] = new Integer[t];
        for(int i=0;i<t;i++)
            w[i] = Integer.parseInt(scan.next());

        Integer d[] = new Integer[t];
        for(int i=0;i<t;i++){
            d[i] = 0;
            for(int j=0;j<t;j++){
                if(j<=i)
                    d[i] += w[j];
                else
                    d[i] -= w[j];
            }
            d[i] = Math.abs(d[i]);
        }
        
        System.out.println("\n" + getMin(d));
    }

    static Integer getMin(Integer d[]){
        int min = d[0];
        for(int i=0;i<d.length;i++){
            if(min>d[i])
                min = d[i];
        }
        return min;
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;

    bool flag = false;

    int tmp;
    for (int i = 0; i <= 100; ++i)
    {
        tmp = (a * i) % b;
        if (tmp == c)
        {
            flag = true;
            break;
        }
    }

    if (flag)
    {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>
#include <iomanip>

#define rep(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define FOR(i,s,e) for(int (i) = (s); (i)<(e); (i)++)
#define vecall(itr,vec) for(auto (itr) = (vec).begin(); (itr) != (vec).end(); (itr)++)
#define vecshow(vec) for(auto itr = (vec).begin(); itr != (vec).end(); itr++)cout << *itr << " ";

using namespace std;
using p = pair<int, int>;
using ll = long long;

int gcd(int a, int b) {
	int l = max(a, b);
	int s = min(a, b);
	while (l * s != 0) {
		int tmp = s;
		s = l % s;
		l = tmp;
	}

	return l;
}

vector<vector<int>> path;

int main() {
	char c;
	cin >> c;
	char ans = 'A';
	if ((int)c >= 97)ans = 'a';
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	ll ans=0;
	ll ans1=0;
	FORI(i,0,N)
	{
		READV(x);
		ans+=x;
		ans1+=x*x;
	}
	ans=ans*ans-ans1;
	ans=ans/2;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int Judge(int *a,int *b){
	return *a-*b;
}
int main(){
	int W[10],K[10];
	int ws=0,ks=0;
	int i;
	for(i=0;i<10;i++){
		W[i]=0;
		K[i]=0;
	}
	for(i=0;i<10;i++){
		scanf("%d",&W[i]);
	}
	for(i=0;i<10;i++){
		scanf("%d",&K[i]);
	}
	qsort(W,10,sizeof(int),Judge);
	qsort(K,10,sizeof(int),Judge);
	ws=W[7]+W[8]+W[9];
	ks=K[7]+K[8]+K[9];
	printf("%d %d\n",ws,ks);
	return 0;
}

Measured memory_bytes: 600
n, m = map(int, input().split())
cnt = 0
like = []
frag = 1
for i in range(n):
  s = list(map(int, input().split()))
  like.append(s[1:])
for i in range(m):
  for j in range(n):
    if(not(i+1 in like[j])):
      frag = 0
      break
  if(frag == 1):
    cnt += 1
  frag = 1
print(cnt)

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] a = new int[n];
	foreach (i; 0..n) scanf("%d", &a[i]);
	a.sort;
	int r = a[n-1], l = a[0];
	foreach (i; 0..n-1) {
		if (min(l,r-l) < min(a[i],r-a[i])) l = a[i];
	}
	writefln("%d %d", r, l);
}

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

using namespace std;

void solve(){
	long long int n,m,k; cin>>n>>m>>k;
	long long int a[n+1], b[m+1];
	a[0] = 0, b[0] = 0;
	for(long long int i = 1; i <= n; i++){
		long long int x; cin>>x;
		a[i] = a[i-1] + x;
	}
	for(int i = 1; i <= m; i++){
		long long int x; cin>>x;
		b[i] = b[i-1] + x;
	}
	long long int ans = 0;
	for(long long int i = 0, j = m; i <= n; i++){
		if(a[i] > k){
			break;
		}
		while((b[j] + a[i]) > k){
			j--;
		}
		ans = max(ans, i+j);
	}
	cout << ans << "\n";
}
int main() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1; 
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


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

int main() {
    int n; cin >> n;
    int a[n+1]; // One-based indexing
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int now = 1; // start position

    for (int cnt = 0; cnt < n; cnt++) {
        if (now == 2) { // Button 2 is illuminated
            cout << cnt << endl;
            return 0;
        }
        now = a[now];
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str;

		while ((scan.hasNext())) {
			str = String.valueOf(scan.next());
			char[] chars = str.toCharArray();
			for (int i = chars.length - 1; i >= 0; i--) {
				System.out.print(chars[i]);
			}
			System.out.println();
		}
	}
}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main() {
    int n;
    cin >> n;
    ll a[n],sum=0,tes=0;;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    ll min1 = LINF;
    REP(i,n){
        tes += a[i];
        if(min1>abs(2*tes-sum))min1 = abs(2*tes-sum);
    }
    COUT(min1);
    return 0;
}

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

int main(){
    int r, D, x2000;
    cin >> r >> D >> x2000;

    int old = x2000;
    for(int i = 0; i < 10; i++){
        cout << r * old - D << endl;
        old = r * old - D;
    }

    return 0;
}

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

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

string f(const string &s){
  int n=s.size();
  rep(i, n){
    if(s[i]=='e'){
      if(i-1>=0 && s[i-1]=='m' && i+1<n && s[i+1]=='w'){
        if((i-1==0 && i+2<n) || (i-1>0 && i+2==n)) return s;
        else return f(s.substr(0, i-1)+s.substr(i+2));
      }
    }
  }
  return s;
}

int main(){

  string s; cin>> s;

  auto ret=f(s);
  if(ret.empty()) cout<< "Cat"<< endl;
  else cout<< "Rabbit"<< endl;

  return 0;
}


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

int main (void) {
    int a, b, c;

    cin >> a >> b >> c;

    if (a == b + c) {
        cout << "Yes" << endl;
    }
    else if (b == c + a) {
        cout << "Yes" << endl;
    }
    else if (c == a + b){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;

}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

template<typename temp_type> struct segment_tree {
	// Elements count
	int n;
	
	temp_type tt[4 * MAXN];
	
	// Combine from two values
	temp_type combine(temp_type v1, temp_type v2){
		temp_type tmp = v1 + v2;
		if (tmp >= MOD) {
			tmp -= MOD;
		}
		return tmp;
	}
	
	// Recursive get
	temp_type get_val(int ind, int tl, int tr, int l, int r){
		if (tl == l && tr == r){
			return tt[ind];
		}
		int tm = (tl + tr) >> 1;
		if (r <= tm){
			return get_val(ind << 1, tl, tm, l, r);
		} else if (l > tm){
			return get_val((ind << 1) + 1, tm + 1, tr, l, r);
		} else {
			return combine(get_val(ind << 1, tl, tm, l, tm), get_val((ind << 1) + 1, tm + 1, tr, tm + 1, r));
		}
	}	
	
	// Recursive update (set value)
	void upd_val(int ind, int tl, int tr, int pos, temp_type new_val){
		if (tl == tr){
			tt[ind] = new_val;
			return;
		}
		int tm = (tl + tr) >> 1;
		if (pos <= tm){
			upd_val(ind << 1, tl, tm, pos, new_val);
		} else {
			upd_val((ind << 1) + 1, tm + 1, tr, pos, new_val);
		}
		tt[ind] = combine(tt[ind << 1], tt[(ind << 1) + 1]);
	}
	
	// Get (for call)
	temp_type get_val(int l, int r){
		return get_val(1, 0, n - 1, l, r);
	}
	
	// Recursive update (for call)
	void upd_val(int pos, temp_type new_val){
		upd_val(1, 0, n - 1, pos, new_val);
	}
};

segment_tree<int> tt;

int x[MAXN], y[MAXN];

vector<pii> vv;
map<int, int> compressed;

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, 0, n) {
		scanf("%d", &x[i]);
	}
	REP(i, 0, m) {
		scanf("%d", &y[i]);
	}
	int ind;
	for(ind = 0; ind < n && x[ind] < y[0]; ind++);
	for(int j = 0; ind < n; ind++) {
		while(j < m && y[j] < x[ind]) {
			j++;
		}
		if (j == m) {
			break;
		}
		vv.pb(mp(y[j] - x[ind], -(x[ind] - y[j - 1])));
		compressed[x[ind] - y[j - 1]] = 0;
	}
	compressed[0] = 0;
	int cnt = 0;
	FA(it, compressed) {
		it->_2 = cnt++;
	}
	tt.n = cnt;
	tt.upd_val(0, 1);
	SORT(vv);
	REP(i, 0, SZ(vv)) {
		if (i && vv[i] == vv[i - 1]) {
			continue;
		}
		int pos = compressed[-vv[i]._2];
		tt.upd_val(pos, tt.get_val(0, pos));
	}
	int ans = tt.get_val(0, tt.n - 1);
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 7028
n = int(input())
a = list(map(int,input().split()))

if max(a) == 0:
    print('Yes')
    exit()

if n % 3 != 0:
    print('No')
    exit()

p = n // 3
if 0 in a:
    # a = sorted(a)
    zero = a.count(0)
    if zero != p:
        print('No')
        exit()
    if a.count(max(a)) != p * 2:
        print('No')
        exit()
    print('Yes')
    exit()

a = sorted(a)
# if a[0] == a[p] or a[p] == a[-1] or a[-1] == a[0]:
#     print('No')
if a.count(a[0]) != p or a.count(a[p]) != p or a.count(a[-1]) != p:
    print('No')
else:
    if a[0] ^ a[p] == a[-1]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14116
use proconio::input;

// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;

fn main() {
    input! {
        // s: String
        // n: isize
        x:i32,
    }
    println!("{}", if x<1200 {"ABC"}else{"ARC"});
}


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

const int N = 1e6+7, K = 26;
int tr[N][K];
int cnt[N], par[N];
int sz = 0;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin>>n;

    vector<string> ss(n);
    for (int i=0; i<n; i++)     cin>>ss[i];
    sort(ss.begin(), ss.end(), [](const string &a, const string &b){return a.size() < b.size();});

    long long ans = 0;

    for (string s: ss) {
        int k = s.size();
        reverse(s.begin(), s.end());
        int cur = 0;
        for (char ch: s) {
            int c = ch - 'a';
            if (tr[cur][c] == 0)    {
                tr[cur][c] = ++sz;
                par[sz] = cur;
            }
            cur = tr[cur][c];
        }
        cnt[cur]++;
        vector<bool> av(26, 0);
        for (int i=k-1; i>=0; i--) {
            cur = par[cur];
            av[s[i] - 'a'] = true;

            for (int c=0; c<26; c++) {
                if (tr[cur][c] && av[c])
                    ans += cnt[tr[cur][c]];
            }
        }

    }
    cout<<ans-n<<endl;
}


Measured memory_bytes: 113036
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int K = int.Parse(line);
            int sum = 0;
            for(int i = 1; i <= K; i++)
            {
                for(int j = i; j <= K; j++)
                {
                    for (int k = j; k <= K;k++)
                    {
                        if (i == j && j == k)
                        {
                            sum += gcd(i, j, k);
                        }
                        else if (i == j || j == k)
                        {
                            sum += gcd(i, j, k) * 3;
                        }
                        else
                        {
                            sum += gcd(i, j, k) * 6;
                        }
                    }
                }
            }
            // 200 -> 10813692
            Console.WriteLine(sum);
        }

        public static int gcd(int a, int b, int c)
        {
            int max = a;
            if (max > b) max = b;
            if (max > c) max = c;
            for(int i = max; i > 1; i--)
            {
                if (a % i == 0
                    && b % i == 0
                    && c % i == 0)
                {
                    return i;
                }
            }
            return 1;
        }
    }
}


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

using namespace std;

class InvisibleHand
{
public:
	int n, t;
	vector<int> a;
	InvisibleHand();
	~InvisibleHand();
	void exec();
};

InvisibleHand::InvisibleHand(){
	cin >> n >> t;
	a.resize(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
}

InvisibleHand::~InvisibleHand(){}

void InvisibleHand::exec(){
	int max = a[n-1];
	int dif = 0;
	int count = 0;
	for (int i = n-2; i >= 0; --i)
	{
		if(max - a[i] > dif){
			count = 1;
			dif = max - a[i];
		}else if(max - a[i] == dif){
			count++;
		}
		if(a[i] > max){
			max = a[i];
		}
	}
	cout << count << endl;

}

int main(){
	InvisibleHand ih = InvisibleHand();
	ih.exec();

}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    // c: 入力
    // flag: Y/Nの判定
    int c[3][3], flag = 1;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &c[i][j]);
        }
    }

    // ex) c11 - c12 = (a1 + b1) - (a2 + b1) = a1 - a2
    //     c21 - c22 = (a1 + b2) - (a2 + b2) = a1 - a1
    // このような2値が等しくなるかを確認する
    // 4回のチェックで全体を確認し終える
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            if((c[i][j] - c[i][j + 1]) != (c[i + 1][j] - c[i + 1][j + 1])){
                    flag = 0;
            }
        }
    }

    if(flag){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
H, W = map(int, input().split())

F = [input() for _ in range(H)]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if F[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            L[i][j] = L[i][j - 1] + 1 if j - 1 >= 0 else 1
            U[i][j] = U[i - 1][j] + 1 if i - 1 >= 0 else 1

        if F[i][-1 - j] == "#":
            R[i][-1 - j] = 0
        else:
            R[i][-1 - j] = R[i][-j] + 1 if j > 0 else 1

        if F[- 1 - i][j] == "#":
            D[- 1 - i][j] = 0
        else:
            D[- 1 - i][j] = D[-i][j] + 1 if i > 0 else 1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)


Measured memory_bytes: 179332
#include <bits/stdc++.h>
using namespace std;
#define N 10000000
bool P[N + 1];
void eratos() {
	for (int i = 0; i <= N; i++)
		P[i] = true;
	P[0] = P[1] = false;
	for (int i = 2; i * i <= N; i++)
		if (P[i])
			for (int j = 2; i * j <= N; j++)
				P[i * j] = false;
}
int getQuads(int n) {
	for (int i = n; i >= 13; i--)
		if (P[i] && P[i - 2] && P[i - 6] && P[i - 8])
			return i;
}
int main() {
	eratos();
	int n;
	while (cin >> n && n)
		cout << getQuads(n) << endl;
	return 0;
}

Measured memory_bytes: 12828
#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
inline void chmin(int &x, int v) {
  if (x > v) x = v;
}

int N, M;
vector<int> G[1000], D1[1000], D2[1000];
int dp[1000][1000][2];

int in[1000];
int ord[1000], rev[1000];
void tsort() {
  queue<int> q;
  rep(i, N) for (int t : G[i]) in[t]++;
  rep(i, N) if (in[i] == 0) q.push(i);

  int k = 0;
  while (!q.empty()) {
    int x = q.front(); q.pop();
    rev[k] = x, ord[x] = k++;
    for (int t : G[x]) {
      if (--in[t] == 0) q.push(t);
    }
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    int a, b, t1, t2;
    cin >> a >> b >> t1 >> t2;
    a--, b--;
    G[a].pb(b);
    D1[a].pb(t1);
    D2[a].pb(t2);
  }
  tsort();
  assert(rev[0] == 0 && rev[N-1] == N-1);

  rep(i, N) rep(j, N) rep(k, 2) dp[i][j][k] = INF;
  dp[0][0][0] = 0;

  for (int b=0; b<N; b++) {
    for (int a=0; a<=b; a++) {
      rep(k, 2) {
        if (dp[a][b][k] == INF) continue;
        int x = rev[a];
        rep(i, G[x].size()) {
          int t = ord[G[x][i]], d = (k==1&&t==b)?D2[x][i]:D1[x][i];
          chmin(dp[min(t,b)][max(t,b)][a==b], dp[a][b][k] + d);
        }
      }
    }
  }
  int m = min(dp[N-1][N-1][0], dp[N-1][N-1][1]);
  cout << m << "\n";
  return 0;
}

Measured memory_bytes: 11132
using System;

class main{
	static void Main(){
		string[] str = Console.ReadLine().Trim().Split(' ');
		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		string[] s = new string[50];
		for(int i = 0; i < H; i++){
			s[i] = Console.ReadLine();
		}
		int[] dx = new int[]{1, 0, -1, 0};
		int[] dy = new int[]{0, 1, 0, -1};
		string ans = "Yes";
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(s[i][j] == '#'){
					bool flag = false;
					for(int k = 0; k < 4; k++){
						int nx = i + dx[k];
						int ny = j + dy[k];
						if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
						if(s[nx][ny] == '#') flag = true;
					}
					if(!flag) ans = "No";
				}
			}
		}
		Console.WriteLine(ans);
	}
}

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

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

int main(){
    int n,k;
    cin>>n>>k;
    double P=0;
    for(int i=1;i<=n;i++){
        int m=0;
        double p=1;
        while(i*(pow(2,m))<k){
            m++;
            p*=0.5;
        }
        P+=p;
    }
    cout<<setprecision(10)<<P/n<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = [input() for i in range(H)]
ans = "Yes"
c = [0 for i in range(26)]
for i in range(H):
    for j in range(W):
        c[ord(a[i][j])-ord('a')] += 1
c1 = 0
c2 = 0
c4 = 0

if H == 1 and W == 1:
    ans = "Yes"

elif H % 2 == 0 and W % 2 == 0:
    for i in range(26):
        if not c[i] % 4 == 0:
            ans = "No"
            break

else:
    for i in range(26):
        c4 += int(c[i]/4)
        c2 += int((c[i]%4)/2)
        c1 += c[i]%2
    if c1 != H*W%2:
        ans = "No"
    if H % 2 == 1 and W % 2 == 0 and c2 > (H % 2) * (W / 2):
        ans = "No"
    if H % 2 == 0 and W % 2 == 1 and c2 > (H / 2) * (W % 2):
        ans = "No"
    if H % 2 == 1 and W % 2 == 1 and c2 > int(H / 2) * (W % 2) + (H % 2) * int(W / 2):
        ans = "No"



print(ans)

Measured memory_bytes: 3064
void main() {
	auto A = rs.to!(dchar[]);
	ulong len = A.length;
	auto a = A.sort().group;
	ulong res = len * (len - 1) / 2 + 1;
	foreach(i; a) {
		ulong n = i[1];
		res -= n * (n - 1) / 2;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 3128
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

int abs(int a) {
  return a < 0 ? -a : a;
}

int main() {
  int n, l, tot = 0, red = 10000;
  scanf("%d %d", &n, &l);
  for (int i = 0; i < n; i++) {
    int x = l + i;
    if (abs(x) < abs(red)) red = x;
    tot += x;
  }
  printf("%d\n", tot - red);
  return 0;
}

Measured memory_bytes: 128
N = int(input())-1
l = len(str(N))

ans = ''

if N == 0:
    print('a')
    exit(0)

cnt = 0
while N >= 26:
    d = N % 26
    ans = chr(ord('a') + d) + ans
    N //= 26
    N -= 1
ans = chr(ord('a') + N) + ans

print(ans)


Measured memory_bytes: 9196
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a==0 && b==0)break;
			int[][] map = new int[b+1][a+1];
			int[][] cost = new int[b+1][a+1];
			
			int n = sc.nextInt();
			int x, y;
			for(int i=0;i<n;i++){
				x = sc.nextInt();
				y = sc.nextInt();
				map[y][x]++;
			}
			
			cost[0][1]=1;
			for(int i=1;i<=b;i++){
				for(int j=1;j<=a;j++){
					if(map[i][j]==0)cost[i][j]=cost[i-1][j]+cost[i][j-1];
				}
			}
			System.out.println(cost[b][a]);
				
		}
	
	}	
}

Measured memory_bytes: 20192
#include <iostream>

//
// Input
// S1S2S3
// * S1～3 ... 1 or 0
// Output
// O1
// * O1 ... Inputの"1"の数

int main () {

  char a;
  int b = 0;

  for( int idx = 0; idx < 3 ; idx++) {
    std::cin >> a;
    if ( a == '1') b++;
  }

  std::cout << b << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int t1,t2,a1,a2,b1,b2;
	cin>>t1>>t2;
	cin>>a1>>a2;
	cin>>b1>>b2;
	if((a1>b1 && a2>b2) && (a1<b1 && a2<b2))
	{
		cout<<0;
		return;
	}
	if((t1*a1+t2*a2)==(t1*b1+t2*b2))
	{
		cout<<"infinity";
		return;
	}
	
	int dist1=t1*a1+t2*a2;
	int dist2=t1*b1+t2*b2;
	if(dist2>dist1)
    {
    	swap(a1,b1);
    	swap(a2,b2);
    }
    dist1=a1*t1+a2*t2;
    dist2=b1*t1+b2*t2;
 
    if(a1>b1)
    {
    	cout<<0;
    	return;
    }
 
    int diff=dist1-dist2;
    int cnt=(t1*(b1-a1))/diff;
    int ans=2*cnt+1;
    
    if((t1*(b1-a1))%diff==0)
    ans--;
	cout<<ans;

}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


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

int main (){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;

signed main(){
	int h,w;
	cin >> h >> w;
	vector<string> a(h);
	vector<vector<int>> b(h+2, vector<int>(w+2));
	REP(i,h+2){
		REP(j,w+2){
			b[i][j] = 0;
		}
	}

	REP(i,h){
		cin >> a[i];
		REP(j,w){
			if(a[i][j] == '#'){
				b[i][j] +=1;
				b[i][j+1] +=1;
				b[i][j+2] +=1;
				b[i+1][j] +=1;
				b[i+1][j+2] +=1;
				b[i+2][j] +=1;
				b[i+2][j+1] +=1;
				b[i+2][j+2] +=1;
				b[i+1][j+1] = -10;
			}
		}
	}
	FOR(i,1,h+1){
			FOR(j,1,w+1){
				if(b[i][j] < 0){
					cout << "#";
				}
				else{
					cout << b[i][j];
				}
			}
			cout << endl;
		}


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s; int n = s.length(), ans = 0;
	int a = 0, b = 0;
  	for (int i = 0; i < n; i++) {
     	if (s[i] == '1') a++; else b++;
    }
  	ans = min(a,b)*2;
  	cout << ans << endl;
}


Measured memory_bytes: 512
#!/usr/bin/python3

from itertools import permutations

def main():
    ans = 0
    n, m = map(int, input().split())
    G = [[] for _ in range(n) ]

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1; b -= 1;
        G[a] += [b]
        G[b] += [a]

    a = list(permutations(range(1, n)))

    for i in a:
        ok = True
        for j in range(len(i)):
            tmp = False
            if j == 0:
                for e in G[0]:
                    if e == i[j]:
                        tmp = True
            else:
                for e in G[i[j-1]]:
                    if e == i[j]:
                        tmp = True
            if not tmp:
                ok = False
        if ok:
            ans += 1

    print(ans)

main()

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

const double eps = 1e-3;
int main()
{
	long long a;
	string b;
	cin >> a >> b;
	long long c = 100 * (b[0] - '0') + (b[2] - '0') * 10 + b[3] - '0';
	long long res = a * c / 100;
	cout << res << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        sc.close();

        String[] strArray = S.split("");

        int count=0;
        for (int i=0; i<strArray.length; i++){
            if (strArray[i].equals("o")){
                count++;
            }

        }
        int tmp = 8 - (strArray.length - count);

        if (tmp > 0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }
}

Measured memory_bytes: 22100
def my_clip(value, max):
    if value <= max:
        return value
    return max

A, B, C, K = map(int, input().split())

restK = K
sum = 0

clipA = my_clip(A, restK)
sum += clipA
restK -= clipA

if restK > 0:
    clipB = my_clip(B, restK)
    restK -= clipB

sum -= restK

print(sum)

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N;cin>>N;
    vector<pair<ll,ll>> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i].first>>S[i].second;
    }
    sort(all(S));
    int ans=100;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            ll x=S[j].first-S[i].first;
            ll y=S[j].second-S[i].second;
            int cnt=0;
            for(int k=0;k<N;k++){
                for(int m=0;m<N;m++){
                    if(S[k].first+x==S[m].first&&S[k].second+y==S[m].second) cnt++;
                }
            }
            ans=min(ans,N-cnt);
        }
    }
    if(N==1) cout<<1<<endl;
    else cout<<ans<<endl;
}


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

int main(){
    int x,y;
    cin >> x >>y;
    if(y % 2==0){
    if((y-x*2)/2<=x&&(y-x*2)/2>=0){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    }else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(true){
        int a,b;
        char op;
        cin>>a>>op>>b;
        if(op=='+')cout<<a+b<<endl;
        else if(op=='-')cout<<a-b<<endl;
        else if(op=='*')cout<<a*b<<endl;
        else if(op=='/')cout<<a/b<<endl;
        else return 0;
    }
}


Measured memory_bytes: 3084
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//

        int N, D;
        cin >> N;

        vector<int> vec(N);

        for (int i = 0; i < N; i++)
        {

                cin >> vec[i];
        }
        int ans = 0;
        for (int i = 1; i < N - 1; i++)
        {
                int ma = max({vec[i - 1], vec[i], vec[i + 1]});
                int mi = min({vec[i - 1], vec[i], vec[i + 1]});
                if (vec[i] != ma && vec[i] != mi)
                {
                        ans++;
                }
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (r, D, x2000) = readLine()!!.split(" ").map { Integer.parseInt(it) }
    val resultList = mutableListOf<Int>()
    resultList.add(x2000)
    for (i in 0 until 10) {
        val next = r * resultList.last() - D
        println(next)
        resultList.add(next)
    }
}

Measured memory_bytes: 37920
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)

int main(){
    int n;
    cin >> n;
    vector<int> l(n, 0);
    rep(i, n)
    {
        cin >> l[i];
    }
    int ans = 0;
    sort(l.begin(),l.end());
    REP(i,1,n-1){
        REP(k,i+1,n){
            ans += distance(
                upper_bound(l.begin(),l.begin()+i,l[k]-l[i]),
                lower_bound(l.begin(),l.begin()+i,l[i]+l[k])
                );
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M1 in [1, 3, 5, 7, 8, 10, 12]:
    if D1 == 31:
        print(1)
    else:
        print(0)
elif M1 in [4, 6, 9, 11]:
    if D1 == 30:
        print(1)
    else:
        print(0)
elif M1 == 2:
    if D1 == 28:
        print(1)
    else:
        print(0)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll  long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 200005
#define mod 1000000007
#define pi 3.14159265358979323846

using namespace std;


int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a, b, c, k;
    cin>>a>>b>>c>>k;
    if(b<=a){
        while(k&&b<=a){
            b*=2;
            k--;
        }
    }
     if(c<=b){
        while(k&&c<=b){
            c*=2;
            k--;
        }
    }

    cout<<(a<b&&b<c?"Yes":"No")<<endl;




}


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;

double third_root(double xn, double q){
    if((xn*xn*xn-q)>-0.00001*q  &&  (xn*xn*xn-q)<0.00001*q){
        return xn;
    }
    
    xn = xn-((xn*xn*xn-q))/(3.0*xn*xn);
    return third_root(xn, q);
    
}


int main(void)
{
    long long int q;
    while(cin>>q){
        if(q==-1)break;
        printf("%.6f\n",third_root((double)q/2.0, (double)q));
    }
}

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

int main() {

    int n, s, x;
    cin >> n >> s;
    int xx = s;
    for(int i=0; i<n; i++) {
        cin >> x;
        xx = min(xx, x);
        s -= x;
    }
    cout << n + s/xx << '\n';

    return 0;
}

Measured memory_bytes: 256
def solve(a, b):
    mod = b%a
    if mod == 0:
        return a
    else:
        return solve(mod, a)

N = int(input())
A = list(map(int, input().split()))

minA = min(A)
B = [a%minA for a in A]
print(solve(minA, max(B)))

Measured memory_bytes: 63468
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<complex>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<cstring>
#include<cassert>
using namespace std;
 
#define REP(i,x,n) for(int i = x ; i < (int)(n) ; i++)
#define rep(i,n) REP(i, 0, n)
#define f first
#define s second
#define mp make_pair
#define pb push_back
 
typedef pair<int,int> P;
typedef long long ll;
 
static const int INF = (1<<29);
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
 
int n;
int ch[10000];
 
int del(int idx, int c){
  int total = 0;
  int color = c;
  int l = idx;
  int r = idx + 1;
  while(true){
    int count = 0;
    while(0 <= l && ch[l]==color){
      count++;
      l--;
    }
    while(r < n && ch[r]==color){
      count++;
      r++;
    }
    if(count >= 4){
      total += count;
     // if(l==-1 || r==n) break;
      if(ch[l]==ch[r]) color = ch[l]; 
    }
    else break;
  }
  return total;
}
 
int solve(){
  int count = 0;
  for(int i = 0 ; i < n ;i++){
    for(int j = 1; j <= 3 ; j++){
      if(ch[i]==j) continue;
      int tmp = ch[i];
      ch[i] = j;
      count = max(count,del(i,j));
      ch[i] = tmp;
    }
  }
  return n - count;
}
 
int main(){
  while(cin >> n, n){
    rep(i,n) scanf("%d",&ch[i]);
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
	int n, k;
	cin >> n >> k;
	cout << n - k + 1;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
int deg[10];
int main() {
    LL k, a ,b;
    scanf("%lld%lld%lld", &k, &a, &b);
    LL ans = 0;

    if (a + 2 >= b) {
        ans = k + 1;
    } else {
        ans = a + (b-a) * ((k - a + 1) / 2) + ((k - a + 1) & 1);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	char grade;
	int m, f, r, score;

	while (1) {
		grade = 'F';
		m = 0, f = 0, r = 0, score = 0;
		scanf("%d %d %d", &m, &f, &r);
		if ((m == -1) && (f == -1) && (r == -1)) { break; }

		score = m + f;

		if (m < 0 || f < 0) { grade = 'F'; }
		else if (score >= 80) { grade = 'A'; }
		else if (score >= 65) { grade = 'B'; }
		else if (score >= 50) { grade = 'C'; }
		else if (score >= 30) { 
			grade = 'D'; 
			if(r>=50) { grade = 'C'; }
		}
		printf("%c\n" , grade);
	}

	return 0;
}


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

int main() {
  int n,k=0;
  cin>>n>>k;
  vector<int> vec(n);
  int hoge,sum=0;
  rep(i,k){
    int d=0;
    cin>>d;
    rep(j,d){
      cin>>hoge;
      vec.at(hoge-1)=1;
    }
  }
  rep(i,n){
    sum+=vec.at(i);
  }
  cout<<n-sum;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int w,h;
	char s[1001][1001];
	for(;;){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)break;
		rep(i,h)scanf("%s",s[i]);
		int x,y;
		x=y=0;
		while(s[y][x]!='.' && s[y][x]!='l'){
			char c=s[y][x];
			s[y][x]='l';
			if(c=='v')y++;
			else if(c=='^')y--;
			else if(c=='>')x++;
			else if(c=='<')x--;
		}
		if(s[y][x]=='.')printf("%d %d\n",x,y);
		else puts("LOOP");
	}
	return 0;
}

Measured memory_bytes: 1300
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
one = 0
two = 0
three = 0
for i in range(N):
  if P[i] <= A:
    one += 1
  elif P[i] > A and P[i] <= B:
    two += 1
  else:
    three += 1
ans = min(one,two)
ans = min(ans,three)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
vector<pair<long long, int> > prime_factorization(long long num) {
  vector<pair<long long, int> > res;
  for (long long i = 2; i * i <= num; ++i) {
    if (num % i != 0) continue;
    int exponent = 0;
    while (num % i == 0) {
      ++exponent;
      num /= i;
    }
    res.emplace_back(i, exponent);
  }
  if (num != 1) res.emplace_back(num, 1);
  return res;
}

const int MOD = 1000000007;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  map<int, int> mp;
  FOR(i, 2, n + 1) {
    auto p = prime_factorization(i);
    for (auto a : p) mp[a.first] += a.second;
  }
  long long ans = 1;
  FOR(i, 2, n + 1) if (mp[i] > 0) {
    (ans *= mp[i] + 1) %= MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
# Union Find 木
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


setrecursionlimit(10 ** 6)

N, M = map(int, input().split())
AB = [[int(c) - 1 for c in input().split()] for _ in range(M)]

parent = [-1] * N
inconvenience = N * (N - 1) // 2
result = []
for a, b in AB[::-1]:
    result.append(inconvenience)
    pa, pb = find(parent, a), find(parent, b)
    if pa != pb:
        inconvenience -= parent[pa] * parent[pb]
    unite(parent, a, b)
print(*result[::-1])


Measured memory_bytes: 43440
#include <iostream>
#include <string>
#include <sstream>

int main()
{
        int n;
        std::cin >> n;
        std::stringstream ss;
        ss << n;
        std::string ns = ss.str();
        int sn = 0;
        for (char ch : ns) {
                sn += (ch - '0');
        }
        if (n % sn == 0)
                std::cout << "Yes\n";
        else
                std::cout << "No\n";
        return 0;
}

Measured memory_bytes: 256