akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#define re(i,a,b) for(int i=a;i<=b;i++)
#define _re(i,a,b) for(int i=a;i>=b;i--)
#define for_edge(x) for(int i=head[x];i;i=e[i].nxt)
#define ll long long
#define maxn 100005
#define inf 1e9
using namespace std;
inline int read(){char c = getchar();int ans = 0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){ans = ans*10 + c - '0';c = getchar();}return f*ans;}
//____________________________________________________________________________________________________________________________________________________________________
struct edge
{
	int nxt,to,v;
	edge(int nxt=0,int to=0,int v=0)
	:nxt(nxt),to(to),v(v){};
}e[maxn*2];
int n,head[maxn],TOT,rd[maxn],dp[maxn];
inline void add(int x,int y,int v)
{
	e[++TOT] = edge( head[x],y,v );
	head[x] = TOT;
}
int type[maxn];
ll cnt_V,cnt_E,bo,cnt[3];
void dfs(int x,int c)
{
	if(type[x]==-1) 
	{
		type[x] = c;
		cnt[type[x]]++;
		cnt_V ++;
		for_edge(x)
			cnt_E++ , dfs( e[i].to , (c+e[i].v+3)%3 );
			
	}
	if(type[x]!=c)
		bo = 1;
}
int main()
{
	int n = read() , m = read();
	re(i,1,m)
	{
		int  x = read() , y = read();
		add(x,y,1);add(y,x,-1);
	}
	ll ans = 0;
	re(x,1,n)
		type[x] = -1;
	re(x,1,n)
		if(type[x]==-1)
		{
			cnt[0] = cnt[1] = cnt[2] = cnt_V = cnt_E = bo = 0;
			dfs(x,1);
		//	printf("%lld %lld %lld\n",cnt[0],cnt[1],cnt[2]);
			ans += bo ? cnt_V*cnt_V : ( cnt[0]&&cnt[1]&&cnt[2] ? cnt[0]*cnt[1]+cnt[0]*cnt[2]+cnt[1]*cnt[2] : cnt_E/2 );
		}
		
	printf("%lld\n",ans);
	
	
	
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
//#pragma GCC diagnostic warning "-std=c++11"
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MX ((ll)(1e6+90))
#define ARRS ((ll)(2e5+100))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21


ll q,a,b,k;
map<ll,ll> f1;
map<ll,ll> f2;

int main(){
	cin>>q;
	while(q--){
		cin>>a>>b;
		if(a>b)swap(a,b);
		ll k=a*b;
		ll t=sqrt(k);
		//cout<<endl;
		//cout<<t<<endl;
		ll pas=2ll*t-(1*(t*(t+1)>=k));
		if(t*t==k)pas--;
		pas--;
		if(a==b)pas++;
		//if(a==b)pas++;
		cout<<pas<<endl;


	}




}






Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (1e9)
#else
#define INF (0x7fffffffffffffff)
#endif
#define LINF (0x7fffffffffffffff)

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

#define MAX_V 112345

struct edge
{
  int to;
  int cost;
};

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s)
{
  priority_queue<i_i,vector<i_i>,greater<i_i> > que;
  fill(d,d+V,LINF);
  d[s]=0;
  que.push(i_i(0,s));

  while(!que.empty())
    {
      i_i p=que.top();
      que.pop();

      int v=p.second;
      if(d[v]<p.first) continue;
      int n=G[v].size();
      rep(i,n)
	{
	  edge e=G[v][i];
	  if(d[e.to]>d[v]+e.cost)
	    {
	      d[e.to]=d[v]+e.cost;
	      que.push(i_i(d[e.to],e.to));
	    }	  
	}
    }
}

signed main(void)
{
  in(int,n);

  rep(i,n-1)
    {
      in(int,a,b,c);
      edge temp;
      temp.to=b-1;
      temp.cost=c;
      G[a-1].pb(temp);
      temp.to=a-1;
      G[b-1].pb(temp);
    }

  in(int,q,k);
  V=n;
  dijkstra(k-1);


  rep(i,q)
    {
      in(int,x,y);
      cout<<d[x-1]+d[y-1]<<endl;
    }
  return 0;
}


Measured memory_bytes: 9076
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int64_t, int >prime_factor(int64_t n){map< int64_t, int > ret;for(int64_t i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    string s; cin >> s;
    int ans = 1; char now = s[0];
    REP(i,n) if(s[i]!=now){ans++; now = s[i];}
    out(ans);

    return 0;
}

Measured memory_bytes: 512
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
void print(){cout << endl;} void prints(){}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}

const int mod = 1e9+7;
const int N = 1e6+1;

int32_t main(){
	fast_io();

	char c; cin >> c;
	c++;
	print(c);

	return 0;
}

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

int main() {
	int q, n, m, i, j, a, b, d, cnt, max;

	cin >> q;

	for (i = 0; i < q; i++) {
		cnt = 0; 
		cin >> n;

		while (n / 10 != 0) {
			d = 1; m = n; max = 0;

			while (m / 10 != 0) {
				m /= 10;
				d++;
			}

			for (j = 1; j < d; j++) {
				a = n / pow(10, j);
				b = n - a * pow(10, j);
				if (a * b > max) {
					max = a * b;
				}
			}

			n = max;
			cnt++;
		}
		
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1204
from math import sqrt
q = int(input())

class Segment:pass

def add(a,b):
    return [a[0] + b[0],a[1] + b[1]]
def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]
def multi(k, a):
    return [k*a[0],k*a[1]]
def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]
def norm(a):
    return sqrt(a[0] ** 2 + a[1] ** 2)    
    
for i in range(q):
    xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3 = map(int, input().split())
    s1 = Segment()
    s2 = Segment()
    s1.p1 = [xp0, yp0]
    s1.p2 = [xp1, yp1]
    s2.p1 = [xp2, yp2]
    s2.p2 = [xp3, yp3]    
    base = sub(s2.p2, s2.p1)
    d1 = abs(cross(base, (sub(s1.p1, s2.p1))))/norm(base)
    d2 = abs(cross(base, (sub(s1.p2, s2.p1))))/norm(base)
    t = d1/(d1+d2)
    x = add(s1.p1 , multi(t,sub(s1.p2, s1.p1)))
    print(x[0],x[1])

Measured memory_bytes: 5696
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<set>
#define ll long long int

using namespace std;

int n , k;
set<int>d;
int main(){
  cin>>n>>k;
  int x;
  for(int i=0;i<k;i++){
    cin>>x;
    d.insert(x);
  }

  for(int i=n;i<=100000;i++) {
    int temp = i;
    bool ok = true;
    while(temp!=0){
      int last = temp%10;
      temp/=10;
      if(d.count(last)){
        ok = false;
      }
    }
    if(ok){
      cout<<i<<endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
ll ans;
priority_queue<double>q;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		q.push(a);
	}
	for(int i=1;i<=m;i++){
		int u=q.top();
		q.pop();
		u/=2.0;
		q.push(u);
	}
	while(!q.empty()){
		ans+=(ll)round(q.top());
		q.pop();
	}
	printf("%lld\n",ans); 
	return 0;
} 

Measured memory_bytes: 1400
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int pow(int x, int e) {
  int v = 1;
  for (int i = 0; i < e; i++) v *= x;
  return v;
}

int main() {
  int X;
  while (cin >> X) {
    int res = 1;
    for (int p = 2; p < 10; p++) {
      int z = pow(X, 1.0 / p);
      int b = max(2, z - 10);
      for (;;) {
        int r = pow(b, p);
        if (r > X) break;
        res = max(res, r);
        ++b;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
using Graph = vector<vector<int>>;

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int dx, dy;
	dx = x2 - x1;
	dy = y2 - y1;

	cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;

	/*if (0 < x2 - x1 && 0 <= y2 - y1)
	{
		cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
	}
	else if (x2 - x1 <= 0 && 0 < y2 - y1)
	{
		cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
	}
	else if (x2 - x1 < 0 && y2 - y1 <= 0)
	{
		cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
	}
	else
	{
		cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
	}*/

	return 0;
}

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

using namespace std;

using ll = long long;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

ll comb(int n, int k)
{
    static bool initiated = false;
    static vector<ll> fact(200010, 1), inv(200010, 1);
    if (!initiated)
    {
        initiated = true;
        for (int i = 2; i <= 200000; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = mypow(fact[i], MOD - 2);
        }
    }
    if (k < 0 || n < k)
    {
        return 0;
    }
    ll ret = fact[n] * inv[k] % MOD;
    ret = ret * inv[n - k] % MOD;
    return ret;
}

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

    int b, w;
    cin >> b >> w;
    vector<ll> p(200010, 0), q(200010, 0);
    ll two = 2, inv = mypow(ll(2), MOD - 2);
    cout << inv << endl;
    for (int i = 1; i < b + w; i++)
    {
        p[i] = p[i - 1] + comb(i - 1, b - 1) * mypow(two, MOD - 2);
        q[i] = q[i - 1] + comb(i - 1, w - 1) * mypow(two, MOD - 2);
        p[i] %= MOD;
        q[i] %= MOD;
        two = two * 2 % MOD;
        ll ret = (1 - p[i] + q[i] + MOD) * inv % MOD;
        cout << ret << endl;
    }
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

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

int		main(void)
{
	int N;
	cin >> N;
	vector<int> M(N);
	for (int i = 0; i < N; i++)
		cin >> M[i];
	sort(rall(M));
	int ans = M[0];
	for (int i = 1; i < N; i++)
		ans = gcd(ans, M[i]);
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main ()
{
	int n, k;
	scanf ("%d %d", &n, &k);
	char string[n];
	scanf ("%s", &string);
	for (int i=0; i<n; i++)
	{
		if (i==(k-1)) string[i]+=32;
	}
	printf ("%s", string);
	return 0;
}

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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    for(int i = 0; i < m; i++){
        cin >> s[i] >> c[i];
    }
    int lim = 1;
    for(int i = 0; i < n; i++){
        lim *= 10;
    }
    int start = lim/10;
    if(lim == 10) start = 0;
    if(m == 0){
        cout << start << endl;
        return 0;
    }

    string num_str;
    bool ans_flag;
    for(int i = start; i < lim; i++){
        ans_flag = true;
        num_str = to_string(i);
        for(int j = 0; j < m; j++){
            if(num_str[s[j]-1]-'0' != c[j]){
                ans_flag = false;
            }
        }
        if(ans_flag){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

namespace comb {
	ll fact[500001];
	ll fact_inv[500001];
	const ll MOD = 1000000007;

	ll modpow(ll a, ll b) {
		ll base = 1, kakeru = a;
		while (b > 0) {
			if (b & 1)base *= kakeru, base %= MOD;
			kakeru *= kakeru, kakeru %= MOD;
			b >>= 1;
		}
		return base;
	}

	void setup() {
		fact[0] = 1, fact[1] = 1;
		for (int i = 2; i <= 500000; i++) {
			fact[i] = (fact[i - 1] * i) % MOD;
		}

		fact_inv[500000] = modpow(fact[500000], MOD - 2);

		for (int i = 499999; i >= 0; i--) {
			fact_inv[i] = fact_inv[i + 1] * (i + 1);
			fact_inv[i] %= MOD;
		}

	}

	ll combination(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[b], ret %= MOD;
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll permutation(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll homogeneous(int a, int b) {
		return combination(a + b - 1, b);
	}

}

int main() {

	comb::setup();

	int N;
	ll M;
	cin >> N >> M;
	vector<int> tmp;
	int waru = 2;
	int before = -1;
	while (waru * waru <= M) {
		if (M % waru == 0) {
			int cnt = 0;
			while (M % waru == 0) {
				M /= waru, cnt++;
			}
			tmp.push_back(cnt);
		}
		waru++;
	}
	if (M != 1)tmp.push_back(1);
	ll ans = 1;

	for (int i = 0; i < tmp.size(); i++) {
		ans *= comb::homogeneous(N, tmp[i]);
		ans %= comb::MOD;
	}

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


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

ll t[200000];
ll a[200000];
ll h[200000];
ll m[200000];
const ll INF = 3000000000;
const ll MOD = 1000000007;

int main(void){
  int n;
  ll ans = 1;
  cin >> n;
  rep(i,200000)h[i] = -1;
  rep(i,200000)m[i] = INF;

  rep(i,n){
    cin >> t[i];
  }
  rep(i,n){
    cin >> a[i];
  }



  h[0] = t[0];
  m[0] = t[0];
  for(int i = 1; i < n; i++){
    if(t[i] != t[i-1]){
      h[i] = t[i];
    }
    m[i] = t[i];
  }

  if(h[n-1] != -1 && h[n-1] != a[n-1]){
    cout << "0" << endl;
    return 0;
  }
  h[n-1] = a[n-1];

  m[n-1] = min(m[n-1], a[n-1]);
  for(int i = n-2; i >= 0; i--){
    if(a[i] != a[i+1]){
      if(h[i] != -1 && h[i] != a[i]){
        cout << "0" << endl;
        return 0;
      }
      h[i] = a[i];
    }
    m[i] = min(m[i], a[i]);
  }

  rep(i,n){
    if(h[i] != -1 && (h[i] > a[i] || h[i] > t[i])){
        cout << "0" << endl;
      return 0;
    }
  }


  rep(i,n){
    if(h[i] == -1){
      ans *= m[i];
      ans %= MOD;
    }
  }


  cout << ans << endl;

  return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int n, a[N], dp[N], k;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    memset(dp, 0x3f, sizeof dp);
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i - j < 1) break;
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
        }
    }
    
    cout << dp[n];
    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, n + 1) {
        ll con = n / (ll)i;
        ans += con * (con + 1) / 2 * i;
    }
    cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:59:01 +0900
# LastModified: 2020-06-27 14:04:38 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    s = list(set(s))
    print(len(s))
        


if __name__ == "__main__":
    main()


Measured memory_bytes: 35712
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define ALL(vec) vec.begin(), vec.end()
typedef signed long long ll;
typedef unsigned long long ull;

void solve() {
    ll a, b;
    cin >> a >> b;
    if((a*b*1 % 2 == 1) || (a*b*2 % 2 == 1) || (a*b*3 % 2 == 1))
        ECHO("Yes")
    else
        ECHO("No")
}

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

#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif

    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

template<ll mod>
class Fp {
public:
	ll val;

private:
	inline void calc_mod(ll& v) {
		if (v >= mod)v -= mod;
	}
public:
	Fp() {}
	Fp(ll v) :val(v%mod) {
		if (val < 0)val += mod;
	}

	Fp operator+=(const Fp &in) {
		val += in.val;
		calc_mod(val);
		return *this;
	}

	Fp operator+(const Fp &in) const {
		return Fp(*this) += in;
	}

	Fp &operator-=(const Fp &in) {
		val -= in.val;
		calc_mod(val);
		if (val < 0)val += mod;
		return *this;
	}

	Fp operator-(const Fp &in) const {
		return Fp(*this) -= in;
	}

	Fp& operator*=(const Fp& in) {
		val = val * in.val % mod;
		return *this;
	}

	Fp operator*(const Fp &in) const {
		return Fp(*this) *= in;
	}

	Fp& operator/=(const Fp& in) {
		*this *= modpow(in, mod - 2);
		return *this;
	}

	Fp operator/(const Fp& in) const {
		return Fp(*this) /= in;
	}

	bool operator==(const Fp&in)const {
		return val == in.val;
	}

	bool operator!=(const Fp&in)const {
		return val != in.val;
	}

	friend Fp modpow(const Fp& in, ll n) {
		if (n == 0)return 1;
		if (n & 1) {
			return in * modpow(in*in, n / 2);
		}
		else {
			return modpow(in*in, n / 2);
		}
	}
};
using modll = Fp<mod>;

class Factorial {
public:
	vector<modll> fact, finv;
	Factorial(ll n) :fact(n+1, modll(1)), finv(n+1, modll(1)) {
		for (int i = 2; i <= n; i++) {
			fact[i] = fact[i - 1] * i;
			finv[i] = finv[i - 1] / i;
		}
	}

	modll com(const ll& n, const ll& k) {
		if (n < k || n < 0 || k < 0)return modll(0);
		return fact[n] * finv[k] * finv[n - k];
	}
};


int main() {
	while (cin >> N >> A >> B >> C) {
		Factorial f(2 * N);
		modll ans = 0;
		for (M = N; M < 2 * N; M++) {
			ans += f.com(M - 1, N - 1)*(modpow(modll(A), N)*modpow(modll(B), M - N) + modpow(modll(A), M - N)*modpow(modll(B), N))*modll(M)*modll(100) / (modpow(modll(A+B), M) * modll(100 - C));
		}
		cout << ans.val << endl;
	}
}


Measured memory_bytes: 3328
H,W,K=map(int,input().split())
F=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    cnt=0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii)%2==0 or (j>>jj)%2==0 or F[ii][jj]==".":
          continue
        cnt+=1
    if cnt==K:
      ans+=1
print(ans)

Measured memory_bytes: 9192
import collections

n = input()
n = int(n)
alist = input().split(" ")
intalist = [int(s) for s in alist]
setalist = list(set(intalist))
# print(setalist)
c = collections.Counter(intalist)
# print(c)
result = [0] * n
if n == 1:
    print(0)
else:
    for i in range(0,n):
        try:
            result[setalist[i] - 1] = c[setalist[i]]
            # print(c[setalist[i]])
        except IndexError:
            pass
for i in range(0,n):
    print(result[i])

Measured memory_bytes: 53404
/*input
20
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 2;

int res[N];

inline int f(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + x * z;
}

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

  int n; cin >> n;

  int m = (int)sqrt(n) + 1;
  for (int x = 1; x <= m; ++x) {
    for (int y = 1; y <= m; ++y) {
      for (int z = 1; z <= m; ++z) {
        res[f(x, y, z)]++;
      }
    }
  }

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

  return 0;
}

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

using namespace std;

int main(void)
{
    string a, b;
    cin >> a >> b;

    auto c = stoul(a + b);
    unsigned long d = sqrt(c + 0.2);

    cout << (c == d*d ? "Yes" : "No") << endl;

    return 0;
}

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

int main(void) {
    int a, b ;

    cin >> a >> b ;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
        cout << a * b << endl ;
    else
        cout << "-1" << endl ;

    return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int a[105];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> a[i];
	}

	int sum = 0;
	FOR(i, N, 1)
	{
		if (a[i] == a[i - 1])
		{
			sum++;
			a[i] = -1;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define N 100005
int n, a[N], mx[N][19], l[N], nl[N], r[N], nr[N];
long long ans;
int getl(int x, int v){
	for (register int i = 18; ~i; --i)
		if (x - (1 << i) + 1 > 0 && mx[x - (1 << i) + 1][i] <= v) x -= 1 << i;
	return x;
}
int getr(int x, int v){
	for (register int i = 18; ~i; --i)
		if (x + (1 << i) - 1 <= n && mx[x][i] <= v) x += 1 << i;
	return x;
}
int main(){
	scanf("%d", &n);
	for (register int i = 1; i <= n; ++i) scanf("%d", a + i), mx[i][0] = a[i];
	for (register int j = 1; j <= 18; ++j)
		for (register int i = 1; i <= n - (1 << j) + 1; ++i)
			mx[i][j] = std :: max(mx[i][j - 1], mx[i + (1 << (j - 1))][j - 1]);
	for (register int i = 1; i <= n; ++i){
		l[i] = getl(i - 1, a[i]), r[i] = getr(i + 1, a[i]);
		// printf("%d %d\n", l[i], r[i]);
		if (l[i] > 0){
			nl[i] = getl(l[i] - 1, a[i]);
			ans += 1ll * (l[i] - nl[i]) * (r[i] - i) * a[i];
		}
		if (r[i] <= n){
			nr[i] = getr(r[i] + 1, a[i]);
			ans += 1ll * (nr[i] - r[i]) * (i - l[i]) * a[i];
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 9472
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll el[99],er[99],ec[99],ecnt;
int main(){
	rep(i,0,18){
		el[ecnt]=i+1;er[ecnt]=i;ec[ecnt]=0;ecnt++;
		el[ecnt]=i+1;er[ecnt]=i;ec[ecnt]=1LL<<i;ecnt++;
	}

	ll k;
	scanf("%lld",&k);

	ll done=0;
	for(ll i=18;done<k;){
		if(done+(1LL<<i)<=k){
			el[ecnt]=19;er[ecnt]=i;ec[ecnt]=done;ecnt++;
			done+=1LL<<i;
		}else{
			i--;
		}
	}
	printf("20 %lld\n",ecnt);
	rep(i,0,ecnt)printf("%lld %lld %lld\n",20-el[i],20-er[i],ec[i]);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#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 _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
char c;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> c;
	cout <<(char) (c + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N;
	string S;
	cin >> N >> S;

	bool updated = true;
	while (updated) {
		updated = false;
		int32_t sum = 0;
		for (size_t i = 0; i < S.size(); i++) {
			if (S[i] == '(') {
				sum++;
			} else {
				sum--;
			}
			if (sum < 0) {
				S = '(' + S;
				updated = true;
				break;
			}
		}
		if (sum > 0) {
			S = S + ')';
			updated = true;
		}
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
N, A, B, C = gets.chomp.split(" ").map(&:to_i)
LS = []
INF = 10 ** 9
N.times do
  LS << gets.chomp.to_i
end

@ans = INF

def dfs(i, a_length, b_length, c_length)
  if i == N
    if [a_length, b_length, c_length].include?(0)
      return INF
    else
      return (a_length - A).abs + (b_length - B).abs + (c_length - C).abs
    end
  end

  # どの材料にもしない場合
  @ans = [@ans, dfs(i + 1, a_length, b_length, c_length)].min
  # Aの材料にする場合
  @ans = [@ans, dfs(i + 1, a_length + LS[i], b_length, c_length) + 10].min
  # Bの材料にする場合
  @ans = [@ans, dfs(i + 1, a_length, b_length + LS[i], c_length) + 10].min
  # Cの材料にする場合
  @ans = [@ans, dfs(i + 1, a_length, b_length, c_length + LS[i]) + 10].min

  # 全探索後 ans を返す
  return @ans
end

puts dfs(0 ,0 ,0 ,0) - 30

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (a, b) = Read2Longs();
            if(a*b % 2 == 0)
            {
                return "Even";
            }
            else
            {
                return "Odd";
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28136
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int X,Y,Z;
signed main(){
    scanf("%lld %lld %lld",&X,&Y,&Z);
    int ans=0;
    printf("%lld %lld %lld\n",Z,X,Y);
    return 0;
}


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

int main() {
    std::string S;
    std::cin >> S;

    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
        std::printf("Bad\n");
    } else {
        std::printf("Good\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


int main()
{
	ll N, M;
	cin >> N >> M;
	lls A;
	cinv(A, N);

	std::multiset<ll> mset;

	for (auto e : A) {
		mset.insert(e);
	}

	for (ll i = 0; i < M; i++) {
		auto it = mset.end();
		it--;
		ll temp = *it;
		mset.erase(it);
		mset.insert(temp / 2);
	}

	ll sum = 0;
	for (auto e : mset) {
		sum += e;
	}

	cout << sum << '\n';
	
	return 0;
}



Measured memory_bytes: 5760
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

char board[510][510];
int row[510], col[510];
signed main() {
    int N; cin >> N;

    int cnt_black = 0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            cin >> board[i][j];
            if(board[i][j] == '#') {
                cnt_black++;
                row[i]++;
                col[j]++;
            }
        }
    }

    if(cnt_black == 0) {
        cout << -1 << endl;
    }
    else {
        int mi = INF, idxR = -1, idxC = -1;
        for(int i=0; i<N; i++) {
            if(col[i] > 0) {
                int val = N - row[i];
                mi = min(mi, val);
            }
            else {
                int val = N - row[i] + 1;
                mi = min(mi, val);
            }
        }

        int ans = mi;
        /*
        for(int i=0; i<N; i++) {
            if(board[idxC][i] == '#') continue;
            ans++;
            vector<int> pat(N);
            for(int j=0; j<N; j++) {
                pat[j] = board[idxR][j];
            }

            for(int j=0; j<N; j++) {
                if(board[j][i] == '#' and pat[j] == '.') {
                    row[j]--;
                    col[i]--;
                }
                if(board[j][i] == '.' and pat[j] == '#') {
                    row[j]++;
                    col[i]++;
                }
                board[j][i] = pat[j];
            }
        }
        */

        // fprintf(stderr, "in progress ... %lld\n", ans);
        for(int i=0; i<N; i++) {
            ans += (col[i] < N);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 764
# DDCC A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
x,y = nm()
ans = 0
if x==3:
    ans += 100000
elif x==2:
    ans += 200000
elif x==1:
    ans += 300000

if y==3:
    ans += 100000
elif y==2:
    ans += 200000
elif y==1:
    ans += 300000

if x==1 and y==1:
    ans += 400000

print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int h,w;cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<bool> b(h),c(w);
  rep(i,h)rep(j,w){
    if(a[i][j]=='#')b[i]=c[j]=true;
  }
  rep(i,h){
    if(b[i]){
      rep(j,w){
        if(c[j])cout<<a[i][j];
          if(j==w-1)cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 3572
import math

class common_function():
    """
        1. よく使いそうで予め用意しておいた変数をまとめた
        2. よく使いそうな関数群をまとめた
    """
    def lcm(self, x:int, y:int):
        """
            最小公倍数を返すメソッド
            math をインポートする
        """
        return (x * y) // math.gcd(x, y)
        

def main():
    common = common_function()
    N, M = map(int, input().split())
    S = input()
    T = input()
    lengthX = common.lcm(N, M)
    XdivS = lengthX//N
    XdivT = lengthX//M
    X = []
    for i in range(N):
        j = XdivS*i
        X.append((j, S[i]))
    X.sort(key=lambda x: x[0], reverse=True)
    
    k, x = X.pop()
    for i in range(M):
        j = XdivT*i
        for a in range(lengthX):
            if len(X) == 0:
                break
            if k < j:
                k, x = X.pop()
            else:
                break
        if k == j:
            if x != T[i]:
                print(-1)
                return
    print(lengthX)

if __name__ == "__main__":
    main()


Measured memory_bytes: 19140
package main

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

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()

	for i := K; i < N; i++ {
		//println(i, i-K, p)
		if A[i-K] < A[i] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 12876
#include <stdio.h>

int main(void) {
	int N;
	char S[64];
	int K;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%63s", S) != 1) return 1;
	if (scanf("%d", &K) != 1) return 1;
	for (i = 0; i < N; i++) {
		putchar(S[i] == S[K - 1] ? (unsigned char)S[i] : '*');
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 1644
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    vector<ll> v1(n);
    vector<ll> v2(m);
    for(auto &x:v1)
    {
        cin>>x;
    }
    for(auto &x:v2)
    {
        cin>>x;
    }
    vector<vector<ll> > dp(n+1,vector<ll>(m+1,1));
    dp[0][0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            dp[i][j]=0;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            if(v1[i-1]==v2[j-1])
            {
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%M;//-dp[i-1][j-1];
            }
            else
            {
                dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+M)%M;
            }
        }
    }
//    for(ll i=0;i<=n;i++)
//    {
//        for(ll j=0;j<=m;j++)
//        {
//            cout<<dp[i][j]<<' ';
//        }
//        cout<<endl;
//    }
    cout<<dp[n][m];
    return 0;
}



Measured memory_bytes: 31616
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int n; cin >> n;
    int count=0;
    rep(i, n){
        int l, r; cin >> l>> r;
        count+=r-l+1;
    }
    out(count);
}

Measured memory_bytes: 256
import sys
in1 = sys.stdin.readlines()

#in1 = ['10 15']

K, S = map(int, in1[0].split())

RC = 0
for idx1 in range(K + 1):
    for idx2 in range(K + 1):
        if 0 <= S - idx1 - idx2 <= K:
            RC += 1

print(RC)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) > abs(x - b)) {
        cout << 'B' << endl;
    }else{
        cout << 'A' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    int x[m];
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    sort(x, x + m);
    int ans = x[m - 1] - x[0];
    if(m > 1) {
        vector<int> d(m - 1);
        for(int i = 0; i < m - 1; i++) {
            d[i] = x[i + 1] - x[i];
        }
        sort(d.rbegin(), d.rend());
        for(int i = 0; i < min(n - 1, sz(d)); i++) {
            ans -= d[i];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N;
void func()
{
    cin >> N;
    vector<pair<int, int>> red, blue;
    int a, b;
    rep(i, 0, N)
    {
        cin >> a >> b;
        red.push_back(make_pair(a, b));
    }
    rep(i, 0, N)
    {
        cin >> a >> b;
        blue.push_back(make_pair(a, b));
    }
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    int ans = 0;
    int maxi, maxs;
    for (int i = 0; i < N; ++i)
    {
        maxi = -1, maxs = -1;
        for (int j = 0; j < N; ++j)
        {
            if (red[j].first < blue[i].first && red[j].second < blue[i].second)
            {
                if (red[j].second > maxs)
                    maxi = j, maxs = red[j].second;
            }
        }
        if (maxi != -1)
        {
            ++ans;
            red[maxi].first = INFTY, red[maxi].second = INFTY;
        }
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3652
A,B,C,X,Y = map(int,input().split())
MIN = min(X,Y)

ans1 = A*X + B*Y
ans2 = C*max(X,Y)*2

ans = C*MIN*2
X -= MIN
Y -= MIN
ans += A*X + B*Y

print(min([ans,ans1,ans2]))



Measured memory_bytes: 3060