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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back

using namespace std;

typedef long long int ll;
typedef pair<ll,int> ii;


int main(){
	
	int D; cin >> D;
	if(D==22) puts("Christmas Eve Eve Eve");
	if(D==23) puts("Christmas Eve Eve");
	if(D==24) puts("Christmas Eve");
	if(D==25) puts("Christmas");
	
	return 0;
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false);
    vector<string> A = {"Sunny", "Cloudy", "Rainy"};
    map<string, int> M;
    for (int i = 0; i < 3; i++)
        M[A[i]] = i;
    string str;
    cin >> str;
    int a = M[str];
    cout << A[(a+1)%3] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


string s;
int a[26];

int main(){
	cin>>s;
	if(s.size()==1){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<s.size();i++){
		a[s[i]-'a']++;
	}
	int m=0;

	int tans=INF;
	int ns=s.size();
	for(int i=0;i<26;i++){
		m=i;
		string t4=s;
		ns=s.size();
		int ans=0;
	for(int i=0;i<100;i++){
		//cout<<s.substr(0,ns)<<endl;
		for(int j=0;j<ns-1;j++){
			if(s[j]!=s[j+1])break;
			if(j==ns-2){
				goto A;
				return 0;
			}
		}
		for(int j=0;j<ns-1;j++){
			if(s[j]==(char('a'+m))||s[j+1]==(char('a'+m))){
				s[j]=char('a'+m);
			}
		}
		ans++;
		ns--;
	}
	A:
		tans=min(tans,ans);
		s=t4;
	}
	cout<<tans<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split(" ");
    var ans ;    o = "";
    k = "";
    a = Number(input[0]);
    b = Number(input[1]);
    for(i = 0; i < a; i++){
        o += b;
    }
    for(i = 0; i<b;i++){
        k += a;
    }
    if(a < b)ans = k;
    else ans = o;
    console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>

int main(void) {
	int a,b,c,d;
	scanf("%d",&a);
	if(a%2){
		b=a/2;
		c=a/2+1;
	}else{
		b=a/2;
		c=a/2;
	}
	d=b*c;
	printf("%d",d);
	return 0;
}


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

int main(){
    int n; cin >> n;
    string s, t; cin >> s >> t;
    int m=s.size(); int l=t.size();
    string s_ref="";
    string t_ref="";
    int d=0;

    for(int i=0; i<min(m,l); i++){
        s_ref = s[m-1-i] + s_ref;
        t_ref = t_ref + t[i];
        if(s_ref==t_ref) d=s_ref.size();
    }
    cout << m+l-d << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	map<int,int> odd,even;
	rep(i,n){
		cin >> v[i];
		if(i%2 == 0) odd[v[i]]++;
		else even[v[i]]++;
	}
	int odd_num[2] = {},odd_max[2] = {}; //max[0] <= max[1]
	for(auto x: odd){
		if(x.second >= odd_max[0]){
			if(x.second >= odd_max[1]){
				odd_num[0] = odd_num[1];
				odd_max[0] = odd_max[1];
				odd_num[1] = x.first;
				odd_max[1] = x.second;
			}else{
				odd_num[0] = x.first;
				odd_max[0] = x.second;
			}
		}
	}
	int even_num[2] = {},even_max[2] = {};
	for(auto x: even){
		if(x.second >= even_max[0]){
			if(x.second >= even_max[1]){
				even_num[0] = even_num[1];
				even_max[0] = even_max[1];
				even_num[1] = x.first;
				even_max[1] = x.second;
			}else{
				even_num[0] = x.first;
				even_max[0] = x.second;
			}
		}
	}
	int ans = INF;
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 2; j++){
			if(odd_num[i] == even_num[j]) continue;
			ans = min(ans,n-odd_max[i]-even_max[j]);
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#include<cstring>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;



int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;
const int MAX = 200000;
const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

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

	return ans;
}
long long nCrM(int n, int r) {
	if (n < r)return 0;
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
		ans %= MOD;
	}

	return ans;
}



long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


ll a[100010];
bool found[100010];
int main() {
	COMinit();
	m0(found);
	ll N; cin >> N;
	ll l=200000, r,d;
	ll dup = 200000;

	REP(i, N+1) {
		cin >> a[i];
		if (found[a[i]]) {
			dup = a[i];
			r = i;
		}
		found[a[i]] = true;
	}

	REP(i, N + 1) {
		if (a[i] == dup) {
			d = r - i;
			break;
		}
	}

	FOR(i, 1, N + 2) {
		ll ans;
		ans = COM(N + 1, i) - COM(N- d, i - 1);
		ans += MOD;
		ans %= MOD;
		cout << ans << endl;
	}
}


Measured memory_bytes: 6784
#include <stdio.h>
int main(void) {
	int h, w, i;

	while (1) {
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)
			break;

		while (h--) {
			for (i = 0; i < w; i++) {
				putchar('#');
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>

int abs(int a){
	if(a>0) return a;
	else return -a;
}

int min(int a, int b){
	if(a>b) return b;
	else return a;
}

int main(void){
	int N;
	int K;
	int h[100000];
	int i,j;

	scanf("%d %d",&N ,&K);
	for(i=0; i<N; i++) scanf("%d", &h[i]);

	long long c[100000];
	for(i=0; i<N; i++) c[i]=100000000000;
	c[0]=0;
	for(i=1; i<N; i++){
		for(j=i-K; j<i; j++){
			if(j<0)continue;
			c[i] = min(c[i], c[j]+abs(h[j]-h[i]));
		}
	}
	printf("%lld\n",c[N-1] );
}




Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
using namespace std;

int main(void){
  CIN(int, a);
  CIN(int, b);
  
  COUT(a*b/2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

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

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	g_b();
	int n, x, t; cin >> n >> x >> t;
	int p = n / x;
	if ( n % x != 0) p++;
	cout << p*t;
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define int long long
using namespace std;



signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        set<char>s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        int sz=s.size();
        ans+=sz-1;
    }
    cout<<ans;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(a[i] - a[n / 2]);
  }
  cout << ans << endl;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)

using namespace std;

const int maxN=101;
int N,W,V=0;
vector<LL> F[maxN];
int w[maxN], v[maxN];

int main()
{
	// IN;OUT;		
	FASTIO;
	cin >> N >> W;
	for (int i=1; i<=N; i++) {
		cin >> w[i] >> v[i];
		V += v[i];
		F[i].pb(0);
	}
	F[0].pb(0);
	for (int i=1; i<=V; i++) F[0].pb(INF);
	for (int i=1; i<=N; i++) 
		for (int j=1; j<=V; j++) {
			LL U = F[i-1][j];
			if (j>=v[i]) U = min(U, F[i-1][j-v[i]] + w[i]);
			F[i].pb(U);
		}
	int ans = 0;
	for (int i=1; i<=V; i++) 
		if (F[N][i] <= W) ans = max(ans,i);
	cout << ans;
	return 0;
}


Measured memory_bytes: 80252
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(void)
{
	const double PI = 6 * asin(0.5);
	double angle = 0.0;
	double x = 0.0, y = 0.0;

	while(1) {
		int dist, theta;
		scanf("%d,%d", &dist, &theta);

		if(dist == 0 && theta == 0) break;

		x += dist * sin(angle);
		y += dist * cos(angle);
		angle += (theta * PI) / 180;
	}

	cout << (int)x << endl << (int)y << endl;
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << "ABC"<<n<< endl;

	return 0;
}

Measured memory_bytes: 256
//ABC138-D
#include <iostream>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

using Edge = pair<int, int>; //エッジ(本問題では使わない))
using Graph = vector<vector<int>>;	//グラフ

int N, Q;
Graph G;

// res は答え
vector<int> res;

// v:現在のノード p:親ノード
void dfs_recursive(int v, int p) {
	for (auto e : G[v]) {
		if (e == p) continue;	//親ノードにさかのぼらない
		res[e] += res[v];		//親の答えを子に足し合わせる
		dfs_recursive(e, v);	//vから下流に進む，このときvが親ノードになる
	}
}

void dfs(int start) {
	vector<int> visited(N, -1); //訪問フラグ
	stack<int> vstack; //待ち配列
	vstack.push(start);
	while (!vstack.empty()) {
		int v = vstack.top(); // スタックから先頭頂点を取り出す
		vstack.pop();
		visited[v] = 0; //訪問フラグを立てる

		// v から辿れる頂点をすべて調べる
		for (auto nv : G[v]) {
			if (visited[nv] != -1) continue; // すでに発見済みの頂点は探索しない
			res[nv] += res[v];
			vstack.push(nv);
		}
	}
}

void bfs(int start) {
	vector<int> visited(N, -1); //訪問フラグ
	queue<int> que; //待ち配列
	que.push(start);
	while (!que.empty()) {
		int v = que.front(); // キューから先頭頂点を取り出す
		que.pop();
		visited[v] = 0; //訪問フラグを立てる

						// v から辿れる頂点をすべて調べる
		for (auto nv : G[v]) {
			if (visited[nv] != -1) continue; // すでに発見済みの頂点は探索しない
			res[nv] += res[v];
			que.push(nv);
		}
	}
}

int main(void) {
	cin >> N >> Q;
	G.assign(N, vector<int>());
	for (int i = 0; i < N - 1; i++) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	res.assign(N, 0);
	for (int i = 0; i < Q; i++) {
		int x, value; cin >> x >> value;
		x--;
		res[x] += value;
	}
	dfs(0);
	for (auto v : res) cout << v << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 15588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<ll> dp(n + 1, 0);
  dp[0] = 1000;
  
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i];
    for (int j = 0; j <= i; j++) {
      dp[i + 1] = max(dp[i + 1], (dp[j] / a[j]) * a[i] + dp[j] % a[j]);
    }
  }
  cout << dp[n] << endl;
  return 0;
} 


Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
	int n, m;
	char str[255];
	
	scanf("%d %d", &n, &m);
	scanf("%s", str);
	
	str[n - 1] >= 'A' && str[n - 1] <= 'Z' ? : str[n - 1] -= 32;
	str[m - 1] >= 'a' && str[m - 1] <= 'z' ? : str[m - 1] += 32;
	
	printf("%s\n", str);
}

Measured memory_bytes: 1624
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[100009];
bool f[100009];

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    f[a]=true;
  }
  dp[0]=1;
  if(f[1]==false)dp[1]=dp[0];
  for(int i=2;i<=n;i++){
    if(f[i]==false){
      dp[i]=dp[i-1]+dp[i-2];
      dp[i]%=mod;
    }
  }
  cout<<dp[n]<<endl;
  return(0);
}


Measured memory_bytes: 1152
def main(n, t, a, h):
    def formula(t, x): return t - x * 0.006
    res = []

    for _h in h:
        res.append(abs(a - formula(t, _h)))

    print(res.index(min(res)) + 1)


if __name__ == "__main__":
    n = int(input())
    t, a = map(int, input().split(' '))
    h = list(map(int, input().split(' ')))

    main(n, t, a, h)


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

int main() {
  int N, T;
  cin >> N >> T;
  int c[N], t[N];
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
  }
  int ans = 1000;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (t[i] <= T) {
      ans = min(ans,c[i]);
      flag = true;
    }
  }
  if (flag) {
    cout << ans << endl;
  }
  else {
    cout << "TLE" << endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i = 0; i < N; i++) cin >> D[i];
  long long ans = 1;
  vector<long long> num;
  if(D[0] != 0) ans = 0;
  else{
    sort(D.begin(), D.end());
    if(D[1] == 0) ans = 0;
    else{
      int dis = 1;
      for(int i = 1; i < N;){
        long long count = 0;
        while(D[i] == dis && i < N){
          count++;
          i++;
        }
        if(count == 0){
          ans = 0;
          break;
        }
        num.push_back(count);
        dis++;
      }
      for(int i = num.size()-1; i > 0 ; i--){
        for(int j = 0; j < num[i]; j++){
          ans *= num[i-1];
          ans %= 998244353;
        }//j
      }//i
    }//else2
  }//else1
  cout << fixed;
  cout << setprecision(10) << ans << endl;
}

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

using namespace std;

int main() {
  int H, W;
  scanf("%d %d", &H, &W);
  while (H || W) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2) {
          j % 2 ? printf("#") : printf(".");
        } else {
          j % 2 ? printf(".") : printf("#");
        }
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d", &H, &W);
  }
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n, m;
	int a[100], b[100];
	while(true){
		cin >> n >> m;
		if(!(n||m)) break;
		int s1 = 0, s2 = 0;
		for(int i=0;i<n;i++) { cin >> a[i]; s1 += a[i]; }
		for(int i=0;i<m;i++) { cin >> b[i]; s2 += b[i]; }
		if((s1-s2)&1) { cout << -1 << endl; continue; }
		sort(a, a+n); sort(b, b+m);
		int diff = (s2-s1)/2;
		int a1 = -1, a2 = -1;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(a[i]+diff == b[j]) { a1 = a[i]; a2 = b[j]; break; }
			}
			if(a1!=-1) break;
		}
		if(a1 != -1) cout << a1 << " " << a2 << endl;
		else           cout << -1 << endl;
	}
}

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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    for (int i = a; i <= b; i++)
    {
        if(c%i==0)
        {
            count++;
        }
    }
    cout << count << endl;
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int A,B;
  cin>>A>>B;
  if(A<=9&&B<=9)cout<<A*B<<endl;
  else cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline().strip()

MOD = 1000000007  # type: int

def modinv(x):
    return pow(x, MOD - 2, MOD)

def solve(N: int, A: "List[int]"):
    factors = [0 for i in range(10**6 + 1)]
    for x in A:
        i = 2
        while i * i <= x:
            curr = 0
            while x % i == 0:
                curr += 1
                x //= i
            factors[i] = max(factors[i], curr)
            i += 1
        if x > 1:
            factors[x] = max(factors[x], 1)
    lcm = 1
    for i in range(10**6 + 1):
        lcm *= pow(i, factors[i], MOD)
        lcm %= MOD
    ans = 0
    for ai in A:
        ans += lcm * modinv(ai) % MOD
        ans %= MOD
    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 115696
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<math.h>

using namespace std;

int main(){

	int a,b,c;
	cin >> a >> b >> c;
	cout << max(max(a,b),max(b,c)) - min(min(a,b),min(b,c)) <<endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	s := IOInitialize()
	S := String(s)
	strs := strings.Split(S, "")
	indexA := 0
	indexC := 0
	strInt := []byte(strs[0])[0]
	if strInt != 65 {
		fmt.Println("WA")
		return
	}
	cnt := 0
	for i := 2; i < len(strs)-1; i++ {
		strInt := []byte(strs[i])[0]
		if strInt == 67 {
			cnt++
			indexC = i
		}
	}
	if cnt > 1 || cnt == 0 {
		fmt.Println("WA")
		return
	}

	for i := 0; i < len(strs); i++ {
		if i == indexA || i == indexC {
			continue
		}

		strInt := []byte(strs[i])[0]
		if !(97 <= strInt && strInt <= 122) {
			fmt.Println("WA")
			return
		}
	}
	fmt.Println("AC")
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, x;
    cin >> n >> x;
    ll a[100002];
    ll t[100002];
    for(int i = 0; i < n; i++) cin >> a[i];
    fill (t, t + n, 100000000000);
    ll ans = 100000000000000000;
    for(int count = 0; count < n; count++){
        ll sum = x * count;
        for(int i = 0; i < n; i++){
            t[i] = min(t[i], a[(i - count + n) % n]);
            sum += t[i];
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.exec();
	}
	
	public void exec() {
		Scanner sc = new Scanner(System.in);
		
		Double a = sc.nextDouble();
		Double b = sc.nextDouble();
		Double x = sc.nextDouble();
		
		sc.close();
		
		Double v = a * a * b;
		
		if(v/2 >= x){
			System.out.println((Math.atan(((a*b*b*0.5) / x)) / Math.PI) * 180);
		}else {
			System.out.println((Math.atan(2*(a*a*b-x) / (a*a*a)) / Math.PI) * 180);
		}
	}

}



Measured memory_bytes: 25300
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N, K; cin >> N >> K;
  int Q; cin >> Q;

  vector <int> cnt(N);
  for (int i = 0; i < Q; i++){
    int A; cin >> A; A--;
    cnt[A]++;
  }

  for (int i = 0; i < N; i++){
    int point = K - (Q - cnt[i]);
    if (point > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    
  }
  
  
  
  return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

const int match[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

int main()
{
    int N, M;
    cin >> N >> M;
    int A[M];
    REP(i, M)
    {
        cin >> A[i];
        A[i]--;
    }

    vector<array<int, 9>> dp(N + 1, {0});
    bool isMake[N + 1] = {false};
    isMake[0] = true;
    for (int i = 1; i <= N; ++i)
    {
        vector<array<int, 9>> candidate;
        REP(j, M)
        {
            if (i - match[A[j]] >= 0)
            {
                if (isMake[i - match[A[j]]])
                {
                    array<int, 9> current = dp[i - match[A[j]]];
                    current[A[j]]++;
                    candidate.push_back(current);
                    isMake[i] = true;
                }
            }
        }
        if (isMake[i])
        {
            array<int, 9> maxArray = {0};
            int countMaxSet = 0;
            for (auto iter = candidate.begin(); iter != candidate.end(); ++iter)
            {
                int count = 0;
                REP(j, 9) count += (*iter)[j];
                if (count != countMaxSet)
                {
                    if (count > countMaxSet)
                    {
                        countMaxSet = count;
                        maxArray = *iter;
                    }
                }
                else
                {
                    for (int j = 8; j >= 0; --j)
                    {
                        if (maxArray[j] > (*iter)[j]) 
                        {
                            break;
                        }
                        else if (maxArray[j] < (*iter)[j])
                        {
                            maxArray = *iter;
                            break;
                        }
                    }
                }
            }
            dp[i] = maxArray;
        }
    }

    for(int i = 8; i >= 0; --i) REP(j, dp[N][i]) cout << i + 1;
}


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

using namespace std;

int n, m, x;
int res;

void rec_solve(int cur, int cost, vector<pair<int, vector<int>>>& books, vector<int> levels) {
    if (cur == books.size()) {
        for (int i = 0; i < m; ++i) {
            if (levels[i] < x) {
                return;
            }
        }
        res = min(res, cost);
        return;
    }
    // don't pick the book
    rec_solve(cur + 1, cost, books, levels);
    // pick the book
    for (int i = 0; i < m; ++i) {
        levels[i] += books[cur].second[i];
    }
    rec_solve(cur + 1, cost + books[cur].first, books, levels);
}

void solve() {
    cin >> n >> m >> x;

    int c;
    vector<pair<int, vector<int>>> books;
    for (int i = 0; i < n; ++i) {
        cin >> c;
        vector<int> level(m);
        for (auto &l: level) {
            cin >> l;
        }
        books.push_back({c, level});
    }

    res = INT_MAX;
    vector<int> levels(m, 0);
    rec_solve(0, 0, books, levels);
    
    if (res == INT_MAX) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }
}


int main(){

   solve();
  
  return 0;
}

Measured memory_bytes: 3644
import java.util.*;

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

Measured memory_bytes: 23764
//though I'll get a AC, I still have a lot of questions.
//why we should dfs from a point which has son over 2?
//why this way the answer may be zero, and we need to max(ans,1)?
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
typedef unsigned long long ull;
using namespace std;
int n;
int x,y;
vector <int> vec[100005];
int dp[100005];

void dfs(int x,int p)
{
	int res=0;
	for(int i=0;i<vec[x].size();i++)
	{
		if(vec[x][i]==p) continue;
		dfs(vec[x][i],x);
		dp[x]+=dp[vec[x][i]];
		res+=(dp[vec[x][i]]==0);
	}
	dp[x]+=max(res-1,0);
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	rep(n-1)
	{
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	int m=0;
	for(int i=1;i<n;i++)
	{
		if(vec[i].size()>vec[m].size()) m=i; 
	}
	dfs(m,-1);
	cout<<max(dp[m],1)<<endl;
	return 0;
}

Measured memory_bytes: 13824
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#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                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=1000005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int gun(int x,int y)
{
    int ret=(x*y)%mod;
    if(ret<0){ret+=mod;ret=ret%mod;}
    return ret;
}
bitset<M>sv;
vector<int>prime;
int fact[M];
int infact[M];
void sieve()
{
    prime.pb(2);
    for(int i=4;i<M;i=i+2)sv[i]=1;
    for(int i=3;i*i<M;i=i+2)
    {
        if(sv[i]==0){

        for(int j=i*i;j<M;j=j+2*i)
        {
           sv[j]=1;
        }

        }
    }
    for(int i=3;i<M;i=i+2)
    {
        if(sv[i]==0)prime.pb(i);
    }
}
void init()
{
    fact[0]=1;
    infact[0]=1;
    f(i,1,M-1)
    {
        fact[i]=(fact[i-1]*i)%mod;
    }
    infact[M-1]=bigmod(fact[M-1],mod-2);
    rf(i,M-2,1)
    {
        infact[i]=(infact[i+1]*(i+1))%mod;
    }
}
vector<int>p,c;
void prime_factorization(int x)
{
    p.clear();c.clear();
    for(int i=0;prime[i]*prime[i]<=x;i++)
    {
        int cnt=0;
        if(x%prime[i]==0)
        {
            while(x%prime[i]==0)
            {
                x=x/prime[i];
                cnt++;
            }
            p.pb(prime[i]);
            c.pb(cnt);
        }
    }
    if(x>1)
    {
        p.pb(x);
        c.pb(1);
    }
}
int star_bar(int bol,int box)
{
   int ret=fact[bol+box-1];
   ret=gun(ret,infact[box-1]);
   ret=gun(ret,infact[bol]);
   return ret;
}
 main()

{
    fast
    init();
    sieve();
    int n,m;
    cin>>n>>m;
    prime_factorization(m);
    int sz=c.size();
    int ses=1;
    for(int i=0;i<sz;i++)
    {
        ses=gun(ses,star_bar(c[i],n));
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 19984
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

string dfs(string s, ll& lc, ll& rc){
    ll l = 0, r = 0;
    REP(i, s.size()){
        if(r > 0 && s[i] == '('){
            ll llc = 0, lrc = 0, rlc = 0, rrc = 0;
            string ls = dfs(s.substr(0,i), llc, lrc);
            string rs = dfs(s.substr(i, s.size()-i), rlc, rrc);
            if(rrc > 0){
                while(rrc > 0){
                    l > 0 ? l-- : r++;
                    rrc--;
                }
                lc = l; rc = r;
                return ls + rs;
            }
            else{
                lc = l; rc = r;
                return ls + rs;
            }
        }
        if(s[i] == '('){
            r > 0 ? r-- : l++;
        }
        if(s[i] == ')'){
            l > 0 ? l-- : r++;
        }
    }
    lc = l; rc = r;
    if(l > 0){
        REP(i, l) s += ")";
    }
    return s;
}

int main(){
    ll N; cin >> N; string s; cin >> s;
    ll ls, rs;
    string ans = dfs(s, ls, rs);
    REP(i, rs) ans = "(" + ans;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
	long long N;

	cin >> N;
	long long i=0;
	long long ans=1;

	for(i=1;i<=N;i++){
		ans=i*ans%(1000000007);
	}

	cout << ans << endl;
	cin >> i;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	
	int n, k;
	cin >> n >> k;
	long long int r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;


	long long int res = 0;
	for (int i = 0; i < k; i++) {
		for (int j = i; j < t.size(); j += k) {
			if (j >= k && t[j] == t[j - k])
				t[j] = ' ';
			else {
				if (t[j] == 'r')
					res += p;
				else if (t[j] == 'p')
					res += s;
				else
					res += r;
			}
		}
	}
	cout << res << endl;
}









Measured memory_bytes: 512
import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static int n, m;
    private static char[] s, t;
    private static int[][] sp, tp;
    private static short[][] dp;

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            s = in.next().toCharArray();
            t = in.next().toCharArray();
            n = s.length;
            m = t.length;
            sp = new int[2][n + 2];
            tp = new int[2][m + 2];
            dp = new short[n + 2][m + 2];
            sp[0][n] = sp[1][n] = n;
            tp[0][m] = tp[1][m] = m;

            // 不可能な遷移先
            sp[0][n + 1] = sp[1][n + 1] = n + 1;
            tp[0][m + 1] = tp[1][m + 1] = m + 1;
            // とり尽くした
            sp[0][n] = sp[1][n] = n + 1;
            tp[0][m] = tp[1][m] = m + 1;
            // 通常遷移
            for (int i = n - 1; i >= 0; i--) {
                for (int j = 0; j < 2; j++) sp[j][i] = sp[j][i + 1];
                sp[s[i] - '0'][i] = i + 1;
            }
            for (int i = m - 1; i >= 0; i--) {
                for (int j = 0; j < 2; j++) tp[j][i] = tp[j][i + 1];
                tp[t[i] - '0'][i] = i + 1;
            }


            int len = dp(0, 0);
            //Arrays.stream(dp).map(Arrays::toString).forEach(System.out::println);
            int i = 0, j = 0;
            StringBuilder ans = new StringBuilder();
            for (int k = 0; k < len; k++) {
                if (dp(sp[0][i], tp[0][j]) <= dp(sp[1][i], tp[1][j])) {
                    i = sp[0][i];
                    j = tp[0][j];
                    ans.append('0');
                } else {
                    i = sp[1][i];
                    j = tp[1][j];
                    ans.append('1');
                }
            }
            out.println(ans.toString());
        }
    }

    private static short dp(int i, int j) {
        if (i == n + 1 && j == m + 1) return 0;
        if (dp[i][j] > 0) return dp[i][j];
        short res = Short.MAX_VALUE;
        for (int k = 0; k < 2; k++) {
            int di = sp[k][i], dj = tp[k][j];
            short t = dp(di, dj);
            if (t < res) res = t;
        }
        res++;
        return dp[i][j] = res;
    }
}


Measured memory_bytes: 89308
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
ll choose2(ll n) {
  return n*(n-1)/2;
}
int main() {
    int N;
    cin >> N;
    map<int, int>mp;
    vector<int>A(N);
    
    rep(i, 0, N){
        cin >> A[i];
        mp[A[i]]++;
    }
    
    ll total = 0;
    for(auto & p:mp){
        ll num = p.second;
        total += num*(num-1)/2;
    }
    
    rep(i, 0, N){
        ll ans = total;
        ll num = mp[A[i]];
        ans -=  num*(num-1)/2;
        num = num-1;
        ans += num*(num-1)/2;
        cout << ans<< endl;
    }
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<ii, ii> pii;

int main(int argc, char** argv) {
	int x; scanf("%d", &x);
	printf("%s\n", (x >= 30) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int N;
  cin>>N;
  
  int p[11];
  for(int i=0;i<N;++i){
    cin>>p[i];
  }
  
  int max_p=0;
  for(int i=0;i<N;++i){
    max_p=max(max_p,p[i]);
  }
  
  int sum=0;
  for(int i=0;i<N;++i){
    sum+=p[i];
  }
  
  cout<<sum-max_p+max_p/2<<endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, chan;
  vector<int> s, t, c;

  scanf("%d %d", &n, &chan);
  REP(i,n){
    int t1, t2, t3;
    scanf("%d %d %d", &t1, &t2, &t3);
    s.pb(t1);
    t.pb(t2);
    c.pb(t3);
  }

  int table[100001] = {};
  REP(i,n){
    table[s[i] - 1]++;
    table[t[i]]--;
  }

  FOR(i,1,100001){
    table[i] += table[i - 1];
  }

  int ans = 0;
  REP(i,100001){
    ans = max(ans, table[i]);
  }

  printf("%d\n", min(ans, chan));
  return 0;
}



Measured memory_bytes: 2028
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNextLong()) {
            long a = sc.nextLong();
            long b = sc.nextLong();

            System.out.println(gcd(a, b) + " " + lcm(a, b));
        }
    }

    static long gcd(long a, long b) {
        if (a < b) return gcd(b, a);
        if (b == 0) return a;
        return gcd(b, a % b);
    }

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


Measured memory_bytes: 25940
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;
int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    vector<ll> B(N + 1, 0);
    ll ans = 0;
    B[0] = 0;
    rep(i, N) {
        cin >> A[i];
        B[i + 1] = B[i] + A[i];
    }
    rep(i, N) {
        ll sum = (B[N] - B[i + 1]) % MOD;
        ans += A[i] * sum;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main() {
    int X;
    cin >> X;
    int a_count=0, b_count=0;
    while (X>=500){
        X-=500;
        a_count++;
    }
    while (X>=5){
        X-=5;
        b_count++;
    }
    cout << a_count*1000+b_count*5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

string s1, s2;
string ret;
int dp[3005][3005];

string LCS() {
	for (int i = 0; i <= s1.size(); i++) {
		for (int j = 0; j <= s2.size(); j++) {
			// cout << i << j << endl;
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (s1[i - 1] == s2[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	int nowi = s1.size();
	int nowj = s2.size();
	while (nowi > 0 && nowj > 0) {
		if (s1[nowi - 1] == s2[nowj - 1]) {
			ret.pb(s1[nowi - 1]);
			nowi--;
			nowj--;
		}
		else if (dp[nowi - 1][nowj] > dp[nowi][nowj - 1]) {
			nowi--;
		} else nowj--;
	} 
	reverse(all(ret));
	return ret;
}

int main() {
	cin >> s1 >> s2;
	cout << LCS() << endl;
	return 0;
}
		

Measured memory_bytes: 35456
/*
    Problem 6
    https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    int N;
    string S;
    cin >> N >> S;

    vector<int> passwords(1000, 0);
    int n1, n2, n3;
    for (int i = 0; i < N; i++) {
        int cur = S[i] - '0';
        for (int d1 = 0; d1 < 10; d1++) {
            for (int d2 = 0; d2 < 10; d2++) {
                int n1 = cur * 100 + d1 * 10 + d2;
                int n2 = d1 * 100 + cur * 10 + d2;
                int n3 = d1 * 100 + d2 * 10 + cur;
                if (passwords[n3] == 2) passwords[n3]++;
                if (passwords[n2] == 1) passwords[n2]++;
                if (passwords[n1] == 0) passwords[n1]++;
            }
        }
    }

    int ans = 0;
    for (int a : passwords)
        if (a == 3) ans++;
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 100005;

int n,a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int pos = n>>1;
  int ret=a[pos]-a[pos-1];
  cout<<ret<<endl;
  return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  n += 2;
  vi a(n), l(n), r(n);
  a[0] = 0;
  a[n - 1] = 0;
  FOR(i, 1, n - 1) { a[i] = read(); }
  FOR(i, 1, n) { l[i] = l[i - 1] + abs(a[i] - a[i - 1]); }
  for (int i = n - 2; i >= 0; i--) {
    r[i] = r[i + 1] + abs(a[i] - a[i + 1]);
  }
  FOR(i, 1, n - 1) {
    int ans = 0;
    ans += abs(a[i - 1] - a[i + 1]);
    ans += l[i - 1] + r[i + 1];
    print(ans);
  }
}


Measured memory_bytes: 3584