akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Goods{
public:
	int w;
	int p;
	Goods(int _w,int _p) : w(_w), p(_p) {}
};

int dp[101][301];

int main(){
	int s,d,m;

	while(~scanf("%d %d %d",&s,&d,&m)){

		map<int,vector<Goods> > data;

		for(int i=0;i<s;i++){
			int k;
			scanf("%d",&k);

			for(int j=0;j<k;j++){
				int w,p;
				scanf("%d %d",&w,&p);
				data[i].push_back(Goods(w,p));
			}
		}

		vector<int> days;

		for(int i=0;i<d;i++){
			int f;
			scanf("%d",&f);
			days.push_back(f);
		}


		memset(dp,0,sizeof(dp));

		for(int idx=0;idx<days.size();idx++){
			vector<Goods>& it = data[days[idx]];

			int cost[301]; 
			memset(cost,0,sizeof(cost));

			for(int i=0;i < it.size();i++){
					int w = it[i].w;
					int p = it[i].p;
					for(int used=m-p;used>=0;used--){
						cost[used+p] = max(cost[used]+w,cost[used+p]);
					}
			}

			for(int j=0;j<=300;j++){
				for(int used=0;used<=j;used++){
					dp[idx+1][j] = max(dp[idx+1][j],dp[idx][j-used]+cost[used]);
				}
			}
		}

		int resw=0;
		int resm=0;
		for(int i=0;i<=m;i++){
			if(resw < dp[d][i]){
				resm = i;
				resw = dp[d][i];
			}
		}

		printf("%d %d\n",resw,resm);
	}
}

Measured memory_bytes: 1376
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	int N;
	string s, t;
 
	cin >> N >> s >> t;
	int i = 0;
	for (; i < N; ++i) {
		if (s.substr(i) == t.substr(0, N-i)) {
			break;
		}
	}
 
	cout << N + i;
	// your code goes here
	return 0;
}

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

using namespace std;

#define mod 1000000007

struct graph{
	vector<vector<int> > path;
	int v;
	vector<int> route;

	graph(int size){
		v = size;
		path.resize(v);
	}

	void add(int s,int e){
		path[s].push_back(e);
		path[e].push_back(s);
	}

	void term(){
		vector<int> check(v,0);
		for(int i = 0;i < route.size();i++){
			check[route[i]] = 1;
		}
		int p = route[route.size()-1];
		while(true){
			int q = p;
			for(int i = 0;i < path[p].size();i++){
				if(check[path[p][i]] == 0){
					p = path[p][i];
					check[p] = 1;
					route.push_back(p);
					break;
				}
			}
			if(q == p) break;
		}
	}
};

int main(){
	int n,m;
	cin >> n >> m;
	graph g(n);
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b;
		g.add(a-1,b-1);
	}
	g.route.push_back(0);
	g.term();
	reverse(g.route.begin(),g.route.end());
	g.term();
	cout << g.route.size() << endl;
	for(int i = 0;i < g.route.size();i++){
		cout << g.route[i]+1 << ' ';
	}cout << endl;
}


Measured memory_bytes: 7024
def change2sys(n, digi)
  ar = Array.new(0)
  cnt = 0
  while n > 0
    ar.unshift(n % 2)
    n /= 2
    cnt += 1
  end
  for i in 0..(digi-cnt-1)
    ar.unshift(0)
  end
  return ar
end

digi = 30
n = gets.to_i
a = gets.split.map(&:to_i)
xors = Array.new(n).map{Array.new(digi)}
digicnt = Array.new(digi, 0)

for i in 0..(n-1)
  xors[i] = change2sys(a[i], digi)
end

for i in 0..(n-1)
  dbl = 1
  dbl = 2 if i == 0
  for j in 0..(digi-1)
    digicnt[j] += xors[i][j] * dbl
  end
end

flag = 1
for i in 0..(digi-1)
  if digicnt[i] % 2 != xors[0][i]
    flag = 0
    break
  end
end

if flag == 1
  puts "Yes"
else
  puts "No"
end

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll n;
    cin >> n;
    vector<ll> num(n, 0);
    vector<ll> cnt_0(1e5 + 1, 0);
    vector<ll> cnt_1(1e5 + 1, 0);

    ll ans = n;
    for(int i = 0; i < n; i++) cin >> num[i];

    for(int i = 0; i < n ; i += 2){
        cnt_0[num[i]]++;

    }

    for(int i = 1; i < n; i += 2){
        cnt_1[num[i]]++;
    }

    ll max_0 = 0;
    ll max_1 = 0;

    ll max_num_0;
    ll max_num_1;

    for(int i = 0; i < 1e5 + 1; i++){
        max_0 = max(max_0 , cnt_0[i]);
        max_1 = max(max_1 , cnt_1[i]);
        if(max_0 == cnt_0[i]){
            max_num_0 = i;
        }
        if(max_1 == cnt_1[i]){
            max_num_1 = i;
        }        
    }



    sort(cnt_0.begin(), cnt_0.end() ,greater<ll>());
    sort(cnt_1.begin(), cnt_1.end() ,greater<ll>());
    

    if(max_num_0 != max_num_1){
        ans = (n / 2 - cnt_0[0]) + (n / 2 - cnt_1[0]); 
    }else{
        ans = min((n / 2 - cnt_0[0]) + (n / 2 - cnt_1[1]), (n / 2 - cnt_0[1]) + (n / 2 - cnt_1[0]));
    }



    cout << ans << endl;
    

}
//num[i] == num[i + 2] && num[i + 1] == num [i + 3] && num[i] != num[i + 1]

Measured memory_bytes: 2560
s = input()
t = input()
if t in s:
  print("0")
else:
  mindif = 1000
  for i in range(len(s)-len(t)+1):
    ss = s[i:i+len(t)]
    difs = 0
    for j in range(len(t)):
      if ss[j] != t[j]:
        difs += 1
    mindif = min(mindif,difs)
  print(mindif)

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

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

#ifdef LOCAL
#define show(x) cerr<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#else
#define show(x) true
#endif

using namespace std;
using ll=long long;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1e9 + 7;

class Solver {
public:
    Solver(int n) {
        this->N = n;
    }

    bool solve() {
        N /= 10;

        res.resize(4);
        cin >> a >> b >> c >> d;
        REP(l, d + 1) {
            REP(k, c + 1) {
                REP(j, b + 1) {
                    REP(i, a + 1) {
                        int val = i + 5 * j + 10 * k + 50 * l;
                        if (val < N) continue;
                        int ret = change(val);
                        ret += a - i + b - j + c - k + d - l;
                        if (tmp > ret) {
                            tmp = ret;
                            res[0] = i;
                            res[1] = j;
                            res[2] = k;
                            res[3] = l;
                        }
                    }
                }
            }
        }
        REP(i, 4) {
            if (res[i]) {
                cout << coins[i] << " " << res[i] << endl;
            }
        }

        return true;
    }

private:
    int N;
    int a, b, c, d;
    int tmp = INF;

    V<int> res;
    V<int> coins = {10, 50, 100, 500};

    int change(int x) {
        int ret = 0;
        int chg = x - N;
        ret += chg / 50;
        chg %= 50;
        ret += chg / 10;
        chg %= 10;
        ret += chg / 5;
        chg %= 5;
        ret += chg;

        return ret;
    }
};

int main() {
    int N;
    cin >> N;
    while (N) {
        Solver(N).solve();
        if (cin >> N, N) {
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3020
#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>
#include <algorithm>

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int inf = 1e6;

int n, a, b;
int x[100000];
int y[100000];
int d;
int c[100000];
unordered_map<int, set<P>> p, q;
unordered_map<int, vector<int>> f, g;
int u[100000];

vector<int>::iterator lb(vector<int>& v, int x){
  return lower_bound(v.begin(), v.end(), x);
}
vector<int>::iterator ub(vector<int>& v, int x){
  return upper_bound(v.begin(), v.end(), x);
}

void ep(int a, int b){
  p[a].erase(p[a].lower_bound(P(b, -inf)), p[a].upper_bound(P(b, inf)));
  q[b].erase(q[b].lower_bound(P(a, -inf)), q[b].upper_bound(P(a, inf)));
}
void dfsall(set<P>::iterator b, set<P>::iterator a);
void dfs(int i){
  dfsall(p[x[i] - d].upper_bound(P(y[i] + d, inf)), p[x[i] - d].lower_bound(P(y[i] - d, -inf)));
  dfsall(p[x[i] + d].upper_bound(P(y[i] + d, inf)), p[x[i] + d].lower_bound(P(y[i] - d, -inf)));
  dfsall(q[y[i] - d].lower_bound(P(x[i] + d, -inf)), q[y[i] - d].upper_bound(P(x[i] - d, inf)));
  dfsall(q[y[i] + d].lower_bound(P(x[i] + d, -inf)), q[y[i] + d].upper_bound(P(x[i] - d, inf)));
}
void dfsall(set<P>::iterator b, set<P>::iterator a){
  vector<P> v(a, b);
  for(P& k: v){
    if(!u[k.second]){
      ep(x[k.second], y[k.second]);
    }
  }
  for(P& x: v){
    if(!u[x.second]){
      u[x.second] = 1;
      dfs(x.second);
    }
  }
}

int main(){
  cin >> n >> a >> b;
  --a;
  --b;
  rep(i, n){
    int p, q;
    cin >> p >> q;
    x[i] = p - q;
    y[i] = p + q;
  }
  d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
  rep(i, n){
    p[x[i]].insert(P(y[i], i));
    q[y[i]].insert(P(x[i], i));
    f[x[i]].push_back(y[i]);
    g[y[i]].push_back(x[i]);
  }
  for(auto& v: f){
    sort(v.second.begin(), v.second.end());
  }
  for(auto& v: g){
    sort(v.second.begin(), v.second.end());
  }
  rep(i, n){
    c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
    c[i] += ub(f[x[i] + d], y[i] + d) - lb(f[x[i] + d], y[i] - d);
    c[i] += lb(g[y[i] - d], x[i] + d) - ub(g[y[i] - d], x[i] - d);
    c[i] += lb(g[y[i] + d], x[i] + d) - ub(g[y[i] + d], x[i] - d);
  }
  ep(x[a], y[a]);
  u[a] = 1;
  dfs(a);
  ll ans = 0;
  rep(i, n){
    if(u[i]){
      ans += c[i];
    }
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 75796
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
#include <complex>
using namespace std;
  
const double EPS = 1e-9;
const double PI = 3.14159265359;
  
typedef complex<double> P;
 
int main(){
    string s;
 
    while(getline(cin, s)){
        stack<double> st;
        stringstream ss;
 
        ss << s;
        while(ss >> s){
            if(s[0] >= '0' && s[0] <= '9' || s.size() > 1){
                st.push(atoi(s.c_str()));
            }else{
                double a, b;
                b = st.top();
                st.pop();
                a = st.top();
                st.pop();
                switch(s[0]){
                case '+':
                    st.push(a+b);
                    break;
                case '-':
                    st.push(a-b);
                    break;
                case '*':
                    st.push(a*b);
                    break;
                case '/':
                    st.push(a/b);
                    break;
                }
            }
        }
        printf("%lf\n", st.top());
    }
 
    return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;


int main() {
	ll N,K,S;
	cin  >> N >> K >> S;

	
	vector<ll> ans(N);

	rep(i, N) {
		if (i < K) {
			ans[i] = S;
		}
		else {
			ans[i] = 1e9;
			if (S == 1e9) ans[i] = 1;
		}
	}

	

	rep(i, N) {
		if (i == N-1) {
			cout << ans[i] << endl;
		}
		else {
			cout << ans[i] << " ";
		}
	}

	

	return 0;
}


Measured memory_bytes: 2048
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n;
	cin >> n;
	vector<ll> a(3 * n);
	rep(i, 3 * n) cin >> a[i];
	ll ans = -1e18;
	multiset<ll> st;
	ll sum = 0;
	rep(i, n) st.insert(a[i]), sum += a[i];
	vector<ll> p;
	repn(i, n, 3 * n) p.pb(a[i]);
	sort(all(p));
	ll sum2 = 0;
	rep(i, n) sum2 += p[i];
	ans = sum - sum2;
	multiset<ll> av;
	repn(i, n, 3 * n) av.insert(a[i]);
	int nm = n;
	ll sum3 = 0;
	multiset<ll> bst;
	ll mx = 0;
	while(nm--){
		sum3 += *av.begin();
		bst.insert(*av.begin());
		mx = max(mx, *av.begin());
		av.erase(av.begin());
	}
	repn(i, 1, n + 1){
		if(bst.find(a[n - 1 + i]) == bst.end() && av.find(a[n - 1 + i]) != av.end()) av.erase(av.find(a[n - 1 + i]));
		ll sum1 = sum;
		if(a[n + i - 1] > (*st.begin())){
			sum1 -= *st.begin();
			st.erase(st.begin());
			sum1 += a[n + i - 1];
			st.insert(a[n + i - 1]);
		}
		sum = sum1;
		if(a[n - 1 + i] <= mx){
			sum3 -= a[n - 1 + i];
			bst.erase(bst.find(a[n - 1 + i]));
			sum3 += *av.begin();
			mx = max(mx, *av.begin());
			bst.insert(*av.begin());
			av.erase(av.begin());
		}
		ans = max(ans, sum - sum3);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    long long ans = 0;
    map<long long, int> nums;
    nums[sum]++;
    for (int i=0; i<n; ++i) {
        int a; cin >> a;
        sum += a;
        ans += nums[sum];
        nums[sum]++;
    }
    cout << ans << endl;
}

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

int main(){
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> pairs(n);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        pairs.at(i) = make_pair(a, b);
    }
    sort(pairs.begin(), pairs.end());
    ll cnt = 0;
    rep(i, n){
        cnt += pairs.at(i).second;
        if (cnt >= k){
            cout << pairs.at(i).first << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var x = cin.nextInt();
            var m = cin.ArrayInt(n);

            x -= m.Sum();
            Console.WriteLine(m.Count() + x/m.Min());
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s;
  cin >> s;
  rep(i, s.size()){
    if(i%2==0) cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 576
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;


int trace(int a[],int N){
	for(int i=0;i<N;i++){
		if(i>0)
			cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
}

int insertionSort(int a[],int N){
	for(int i=1;i<N;i++){
		int v=a[i];
		int j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		trace(a,N);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	int N,i,j;
	int a[100];
	while(cin>>N){
		for(i=0;i<N;i++)
			cin>>a[i];
		trace(a,N);
		insertionSort(a,N);
	}
	return 0;
}



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

int main(){
	int n,m,t[111],p,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	    cin>>t[i];
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>p>>x;
		int res=0;
		for(int j=1;j<=n;j++){
			if(j!=p)
			    res=res+t[j];
		}
		printf("%d\n",res+x);
	}
	    
	return 0;
}

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

int main() {
    int N,i;
    cin >> N;
    vector<int> X(N),t;

    for(i=0; i<N; i++)
        cin >> X.at(i);
    t = X;
    sort(X.begin(), X.end());

    for(i=0; i<N; i++)
        if(t.at(i) <= X.at(X.size()/2-1))
            cout << X.at(X.size()/2) << endl;
        else if(t.at(i) >= X.at(X.size()/2))
            cout << X.at(X.size()/2-1) << endl;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	bool flag = false;
	while(n > 0){
	    if(n % 10 == 7) flag = true;
	    n /= 10;
	}
	if(flag){
	    cout << "Yes" << endl;
	}
	else{
	    cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> cl(8);
  int cnt = 0, cnt2 = 0;
  for(int i=0; i<n; ++i) cin >> a[i];
  for(int i=0; i<n; ++i){
    if(1<=a[i] && a[i]<=399) cl[0]=true;

    if(400<=a[i] && a[i]<=799) cl[1]=true;

    if(800<=a[i] && a[i]<=1199) cl[2]=true;;

    if(1200<=a[i] && a[i]<=1599) cl[3]=true;

    if(1600<=a[i] && a[i]<=1999) cl[4]=true;

    if(2000<=a[i] && a[i]<=2399) cl[5]=true;

    if(2400<=a[i] && a[i]<=2799) cl[6]=true;

    if(2800<=a[i] && a[i]<=3199) cl[7]=true;

    else if(3200<=a[i]) ++cnt2;
  }
  if(cnt2==n){
    cout << 1 << " " << n;
    return 0;
  }
  for(int i=0; i<8; ++i){
    if(cl[i]==true) cnt++;
  }
  cout << cnt << " " << cnt+cnt2 << endl;
  return 0;
}

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

using ll = long long;
ll a, b, c, ans = 0;

int main() {
    std::cin >> a >> b >> c;
    ll delicious = b + c;
    if (2*b >= delicious) {
        std::cout << delicious << std::endl;
        return 0;
    }
    else {
        ans += 2*b;
        c -= b;
        ans += std::min(a+1, c);
        std::cout << ans << std::endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[105];
unsigned long long n;
int main()
{
//    freopen("infinity.in","r",stdin);
//    freopen("infinity.out","w",stdout);
    scanf("%s",s);
    scanf("%lld",&n);
    if(s[0]!='1')
        printf("%c\n",s[0]);
    else
    { 
        int k=strlen(s),o;
        for(register int i=0;i<k;i++)
            if(s[i]!='1')
            {
                o=i;
                break;
            }
        if(n<=o) printf("1\n");
        else printf("%c\n",s[o]);
    }
    return 0;
}

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

int main() {
  long long N;
  cin >> N;
  
  long long ans = 1;
  
  rep(i, N) {
    ans *= i+1;
    //cout << ans << endl;
    if(ans >= pow(10, 9)+7) ans = ans % 1000000007;
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;
int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>>A(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A[i][j];
    }
  }
  vector<vector<int>>dist(H,vector<int>(W,-1));
  queue<pair<int,int>>q;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(A[i][j]=='#'){
        auto x=make_pair(i,j);
        q.push(x);
        dist[i][j]=0;
      }
    }
  }
  vector<int>dx={0,0,1,-1};
  vector<int>dy={1,-1,0,0};
  while(!q.empty()){
    auto a=q.front();q.pop();
    for(int i=0;i<4;i++){
      int h=a.first+dy[i];
      int w=a.second+dx[i];
      if(h<0||h>=H||w<0||w>=W){continue;}
      if(dist[h][w]!=-1){continue;}
      dist[h][w]=dist[a.first][a.second]+1;
      q.push(make_pair(h,w));
    }
  }
  int MAX=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      chmax(MAX,dist[i][j]);
    }
  }
  cout<<MAX<<endl;
  return 0;
}


Measured memory_bytes: 16108
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<double> p(N+1);
    for(int i=1; i<=N; i++) cin >> p[i];

    vector<vector<double>> dp(N+1, vector<double>(N+1));
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for(int i=2; i<=N; i++) {
        for(int j=0; j<=i; j++){
            if(j==0)
                dp[i][j] = dp[i-1][j] * (1-p[i]);
            else
                dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i]);
        }
    }

    double ans = 0.0;
    for(int i=(N+1)/2; i<=N; i++) {
        ans += dp[N][i];
    }
    cout<<setprecision(10)<<fixed;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
using namespace std;
int main(){
string s,t;
int f=0;
cin >>s >>t;

for(int i=0; i<s.length(); i++){
if(s[i]!=t[i]) f=1;
}

  if(f==0){
if(s.length()+1 == t.length())cout <<"Yes" <<endl;
  }
else cout <<"No" <<endl;


return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)


int main() {
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double A_angle = 2.0 * M_PI * H / 12.0 + M_PI / 6.0 * M / 60.0;
	double B_angle = 2.0 * M_PI * M / 60.0;
	double diff_angle = abs(A_angle - B_angle);

	printf("%.10f\n", sqrt(A * A + B * B - 2.0 * A * B * cos(diff_angle)));

	return 0;
}

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

int main() {
    int N,K;
    int h[100000];
    cin >> N >> K;
    for(int i=0; i<N; ++i) cin >> h[i];
    int dp[100000];
    fill(dp, dp+N, 1001001001);
    dp[0] = 0;
    for(int i=0; i+1<N; ++i) {
        for(int j=1; j<=K; ++j) {
            if(i+j<N) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	int cnt = 0;
	rep(i, n - 1) {
		if (a[i + 1] <= a[i]) {
			cnt++;
		}
		else {
			chmax(ans, cnt);
			cnt = 0;
		}
	}
	chmax(ans, cnt);
	cout << ans << endl;
}

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

int main(){
	int N;
  	cin >> N;
  	for(int i=1; i<=9; i++){
    	for(int j=1; j<=9; j++){
        	if(N==i*j){
            	cout << "Yes" << endl;
              	return 0;
            }
        }
    }
  	cout << "No" << endl;
	return 0;
}

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

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

struct DisjointSet {
  std::vector<int> rank, p;

  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);

    rep(i, size) makeSet(i);
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  void unite(int x, int y) { link(findSet(x), findSet(y)); }

  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else if (rank[x] < rank[y]) {
      p[x] = y;
    } else {
      p[y] = x;
      rank[x]++;
    }
  }

  int findSet(int x) {
    if (p[x] == x) return x;
    return p[x] = findSet(p[x]);
  }

  int same(int x, int y) { return findSet(x) == findSet(y); }
};

int main() {
  int n, q;
  std::cin >> n >> q;

  DisjointSet ds(n);

  int com, x, y;
  rep(i, q) {
    std::cin >> com >> x >> y;
    if (com == 0)
      ds.unite(x, y);
    else
      std::cout << ds.same(x, y) << '\n';
  }
  return 0;
}



Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int e = (a + d - 1) / d;
  int f = (c + b - 1) / b;
  
  if(e < f) cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

void solve(){
    char c;
    cin >> c;
    if(c >= 'a') cout << 'a' << '\n';
    else cout << 'A' << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

int main(){

    double a,b,n;
    int count = 0,d;
    cin>>n>>d;
    while(n--)
    {
	cin>>a>>b;
	double dist = sqrt(pow(a,2) + pow(b,2));
	if(dist<=d)
	    count++;
    }
    cout<<count;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N) cin >> X.at(i);
    int ans = INFINITY;
    rep(i,100) {
        int sum = 0;
        rep(j,N) {
            sum += (X.at(j) - (i + 1)) * (X.at(j) - (i + 1));
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    size_t N;
    cin >> N;
    set<ll> A;
    rep(i, N)
    {
        ll a;
        cin >> a;
        A.insert(a);
    }
    yes(A.size() == N);
    //
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  vector<LL> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<LL> dp(k+1,0);
  dp[k]=1;
  for(int i=0;i<n;i++){
    vector<LL> rui(k+1,0);
    for(int j=0;j<=k;j++){
      rui[j]=(rui[j]+dp[j])%MOD;
      if(j-a[i]>0) rui[j-a[i]-1]=(rui[j-a[i]-1]-dp[j]%MOD+MOD)%MOD;
    }
    dp[k]=rui[k];
    for(int j=k-1;j>=0;j--){
      rui[j]=(rui[j]+rui[j+1])%MOD;
      dp[j]=rui[j];
    }
  }
  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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

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

	ll N, M;
	cin >> N >> M;

	vector<pair<ll, pair<ll, ll> > > PY(M);

	rep(i, M) {
		cin >> PY[i].first >> PY[i].second.first;
		PY[i].second.second = i;
	}

	sort(PY.begin(), PY.end());
	PY.push_back(make_pair(0, make_pair(0, 0)));

	vector<string> out(M);
	ll count = 0;
	ostringstream a;

	rep(i, M) {
		count++;
		a.str("");
		a << setfill('0') << setw(6) << PY[i].first << flush;
		a << setfill('0') << setw(6) << count << flush;

		out[PY[i].second.second] = a.str();

		if (PY[i].first != PY[i + 1].first)count = 0;
	}

	rep(i, M) {
		cout << out[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 8156
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var x     = int.Parse(spl[0]);
        var y     = int.Parse(spl[1]);

        var c = 0;
        if (x == 1) c += 300000;
        else if (x == 2) c += 200000;
        else if (x == 3) c += 100000;
        
        if (y == 1) c += 300000;
        else if (y == 2) c += 200000;
        else if (y == 3) c += 100000;

        if (x == 1 && y == 1) c += 400000;

        return c;
    }

}


Measured memory_bytes: 11092
S = input()

S = S[::-1]
N = len(S)
cnt = [0] * 2019
mod = 2019
m = 0
cnt[0] += 1
for i in range(N):
    s = int(S[i]) * (pow(10, i, mod))
    s %= mod
    m += s
    m %= mod
    cnt[m] += 1


ans = 0
for i in cnt:
    ans += (i * (i-1)) // 2

print(ans)

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

P = []
M = []
for _ in range(n):
  x, y = map(int, input().split())
  P.append((x, y))
  M.append((x + y) % 2)

if len(set(M)) == 2:
  print(-1)
  exit()

D = [1 << i for i in range(31, -1, -1)]
if M[0] == 0:
  D.append(1)

print(len(D))
print(*D, sep=' ')

for x, y in P:
  a = []
  for d in D:
    if abs(x) > abs(y):
      if x < 0:
        a.append('L')
        x += d
      else:
        a.append('R')
        x -= d
    else:
      if y < 0:
        a.append('D')
        y += d
      else:
        a.append('U')
        y -= d
  print(*a, sep='')

Measured memory_bytes: 4568
while True:
    arr = input().split()
    H = int(arr[0])
    W = int(arr[1])

    if H == 0 and W == 0:
        break
    else:
        flg = True
        odd = ''
        for i in range(W):
            if flg:
                odd += '#'
            else:
                odd += '.'
            flg = not flg

        flg = False
        even = ''
        for i in range(W):
            if flg:
                even += '#'
            else:
                even += '.'
            flg = not flg

        flg = True
        for i in range(H):
            if flg:
                print(odd)
            else:
                print(even)
            flg = not flg

        print('')



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

const int H = 8;
const int W = 5;
string s;
char G[H][W];

int main() {
  while(cin >> s) {
    while(s.size() != W) s.insert(0, "0");
    for(int i = 0; i < W; ++i) {
      int n = s[i]-'0';
      string t = "**=*****";
      t[1-n/5] = t[3+n%5] = ' ';
      for(int j = 0; j < H; ++j) {
        G[j][i] = t[j];
      }
    }
    static bool first = true;
    if(first) first = false;
    else cout << endl;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cout << G[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
ll d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int f(ll a){
  for(int i=2;i<=sqrt(a);i++)if(a%i<1)return 0;
  return 1;
}
int x[1001];
int main(void){
  char s[4],c[4];
  scanf("%s %s",s,c);
  int flg=1;
  FOR(3)if(s[i]!=c[2-i])flg=0;
  char x[2][4]={"NO","YES"};
  PRS(x[flg]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  ll ans = 0;
  rep(i, N) {
    for(int day=1; day <= D; day = day + A[i]) ++ans;
  }
  cout << ans+X << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
  int in[5];
  REP(i,5) cin >> in[i];
  sort(in, in + 5, greater<int>());
  REP(i,4) cout << in[i] << " ";
  cout << in[4] << "\n";
}

Measured memory_bytes: 1180
#include<iostream>
using namespace std;
int main(){
  int a;cin>>a;
  if(a<112)cout<<111<<endl;
  else if(a<223)cout<<222<<endl;
  else if(a<334)cout<<333<<endl;
  else if(a<445)cout<<444<<endl;
  else if(a<556)cout<<555<<endl;
  else if(a<667)cout<<666<<endl;
  else if(a<778)cout<<777<<endl;
  else if(a<889)cout<<888<<endl;
  else cout<<999<<endl;
}


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

using namespace std;

int main()
{
    int x,a,b;
    while(scanf("%d%d%d",&x,&a,&b)==3)
    {
        if(x+a>=b&&a>=b)
        {
            printf("delicious\n");
        }
        else if(x+a>=b&&a<b)
        {
            printf("safe\n");
        }
        else
        {
            printf("dangerous\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r>=0 && x+r<=H && y+r<=H && y-r>=0)printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2 == 1) cout << "No" << endl;
  else{
    int k=n/2;
    bool ans=true;
    for(int i=0; i<k; ++i){
      if(s.at(i) != s.at(i+k)) ans=false;
    }
    if(ans==true) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

long long n, m;
string s, t;

long long gcd(long long x, long long y){
	if(x % y == 0) return y;
	return gcd(y, x % y);
}

long long lcm(long long x, long long y){
	return x * y / gcd(x, y);
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m >> s >> t;
	long long l = lcm(n, m);
//	cout << l << "\n";
	bool f = true;
	long long p = 0;
	long long j = 0;
	for(int i=0; i<n; ++i){
		while(p < l / n * i){
			p += l / m;
			++j;
		}
		if(p == l / n * i && s[i] != t[j]){
			f = false;
			break;
		}
	}
	if(f) cout << l << "\n";
	else cout << -1 << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
using namespace std;

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

	vector<ll> a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(),a.end());
	cout<<a[0]*a[1]/2;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int H, W;

int main() {
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i % 2 == 0 && j % 2 == 0) {
                    cout << '#';
                }
                if (i % 2 == 0 && j % 2 != 0) {
                    cout << '.';
                }
                if (i % 2 != 0 && j % 2 == 0) {
                    cout << '.';
                }
                if (i % 2 != 0 && j % 2 != 0) {
                    cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3092
N,K=(int(i) for i in input().split())
a = [int(input()) for i in range(N)]
a.sort()
ans=9999999999999999999999999999999
for i in range(N-K+1):
    s=a[i+K-1]-a[i]
    ans=min(ans,s)
print(ans)

Measured memory_bytes: 7384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const long long MOD = 1e9 + 7;

class Combination {
    //a^p%mod
    ll powmod(ll a, ll p) {
        ll ans = 1LL;
        ll mul = a;
        // p >>=1 <-> p=(p >> 1)
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    ll mod;
    vector<ll> fact;
    vector<ll> revFact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    ll get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

int main(){
  int H,W,A,B;
  cin >> H >> W >> A >> B;

  Combination comb = Combination(200100,MOD);

  ll ans=0LL;
  for(int i=1;i<=H-A;i++){
    ans+=comb.get((i-1)+(B-1),(B-1))*comb.get((H-i)+(W-B-1),(W-B-1));
    ans%=MOD;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	unsigned long long n, m; cin >> n >> m;
	if (n >= 2 && m >= 2)cout << (n - 2)*(m - 2) << endl;
	else {
		if (n != 1)swap(n, m);
		if (m == 1)cout << 1 << endl;
		else cout << m - 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = B[A[0]-1]
for i in range(1, N):
    ans += B[A[i]-1]
    if (A[i]-A[i-1]) == 1:
        ans += C[A[i-1]-1]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

const ll mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with "n" of "nCk" (maximum number in other words)
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    // nPk - permutation
    mint p(int n, int k) {
        return fact[n] * ifact[n - k];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    combination nck(n);
    mint ans;
    for (int i = 0; i < n; i++) {
        if (i >= k - 1)
            ans += nck(i, k - 1) * mint(a[i]);
        if (n - i - 1 >= k - 1)
            ans -= nck(n - i - 1, k - 1) * mint(a[i]);
    }
    cout << ans.x << endl;
}


Measured memory_bytes: 5540