akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL n, x, d;
	cin >> n >> x >> d;
	
	if(d == 0) { cout << (x == 0 ? 1 : n + 1) << endl; return 0; }
	
	if(d <  0) { x *= -1; d *= -1; }
	
	auto sumID = [](LL l, LL r) { return (r - l) * (l + r - 1) / 2; };
	
	map<LL, vector<pair<LL, int>>> mp;
	incII(c, 0, n) {
		LL m = mo(c * x, d);
		LL l = c * x + d * (sumID(0, 0 + c) + 0);
		LL r = c * x + d * (sumID(n - c, n) + 1);
		mp[m].EB(l, 0);
		mp[m].EB(r, 1);
	}
	
	LL ans = 0;
	RF(v, mp) {
		stack<LL> st;
		sort(ALL(v.SE));
		RF(p, v.SE) {
			if(p.SE == 0) { st.push(p.FI); }
			if(p.SE == 1) {
				LL l = st.top(); st.pop();
				if(st.empty()) { ans += fl(p.FI - l, d); }
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 25216
class BigCombination(object):
    __slots__ = ["mod", "factorial", "inverse"]

    def __init__(self, mod: int = 10**9+7, max_n: int = 10**6):
        fac, inv = [1], []
        fac_append, inv_append = fac.append, inv.append

        for i in range(1, max_n+1):
            fac_append(fac[-1] * i % mod)

        inv_append(pow(fac[-1], mod-2, mod))

        for i in range(max_n, 0, -1):
            inv_append(inv[-1] * i % mod)

        self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

    def get_combination(self, n, r):
        return self.factorial[n] * self.inverse[r] * self.inverse[n-r] % self.mod

    def get_permutation(self, n, r):
        return self.factorial[n] * self.inverse[n-r] % self.mod
import math
Big = BigCombination()
n,k = map(int,input().split())
s = 0
for i in range(k):
    if n - k + 1 < i + 1:
      	print('0')
      	continue
    print((Big.get_combination(n-k+1,i+1) *Big.get_combination(k-1,i))%(10**9+7))



Measured memory_bytes: 90044
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

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

	long long sum= 0;
	for(int i=0; i< s.size(); i++)
		sum+= (s[i]-'0');
	
	if(sum%9==0)
		std::cout<<"Yes"<<std::endl;
	else
		std::cout<<"No"<<std::endl;

	return 0;
}

Measured memory_bytes: 3720
#include<iostream>
using namespace std;
int main(){
  int N, a[1100];
  cin >> N;
  int min = 1000;
  int max = 0;
  for (int i = 0; i < N; i++){
    cin >> a[i];
    if(max < a[i]) max = a[i];
    if(min > a[i]) min = a[i];
  }
  cout << max-min << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string s;
    cin >> s;
    cout << s.front() << s.size() - 2 << s.back() << endl;
    return 0;
}


Measured memory_bytes: 3592
/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[8][2] = {{0, 1}, {1, 0}, {0, -1}, { -1, 0}, {1, 1}, {1, -1}, { -1, -1}, { -1, 1}};
const int mod = 1e9 + 7;
const int gakki = 5 + 2 + 1 + 19880611 + 1e9;
const int MAXN = 2e5 + 5;
const int MAXM = 2e5 + 5;
int to[MAXM << 1], nxt[MAXM << 1], Head[MAXN], tot = 1;
inline void addedge(int u, int v)
{
        to[++tot] = v;
        nxt[tot] = Head[u];
        Head[u] = tot;
}
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int n;
        cin >> n;
        int a, b;
        int anser = INT_MAX;
        for (int i = 1; i < n; i++)
        {
                a = i, b = n - i;
                //cout << a << " " << b << endl;
                int sum1 = 0, sum2 = 0;
                while (a > 0)
                {
                        sum1 += a % 10;
                        a /= 10;
                }
                while (b > 0)
                {
                        sum2 += b % 10;
                        b /= 10;
                }
                anser = min(anser, sum1 + sum2);
        }
        cout << anser << endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int k;
	int pow10[] = new int[10];
	int MAX_N;

	void run() {
		Scanner sc = new Scanner(System.in);
		final int INF = 1 << 28;
		pow10[0] = 1;
		for (int i = 0; i < pow10.length-1; i++) {
			pow10[i + 1] = pow10[i] * 10;
		}
		int a = sc.nextInt();
		MAX_N = (a + "").length();
		int b = sc.nextInt();
		k = sc.nextInt();
		int ans =solve(0, a, b, 0, 0, 0);
		System.out.println(ans);
	}

	int solve(int n, int a, int b, int c, int f, int bor) {
		int ai = a % 10;
		int bi = b % 10;
		int res = 0;
		// 　1. A，B を十進数で表現する。添字は下位から順に 0,1,2,…,n−1 とし、
		// A=An−1An−2…A0，B=Bn−1Bn−2…B0 とする。 n は十進数で表現した時のAの桁数とする。 B の桁数が n
		// より小さいとき、上位桁に 0 を補う。
		// 　2. borrow0=0 とする。
		// 　3. 以下の処理を i=0 から n−1 まで繰り返す。
		// 　　3.1. Ai−borrowi&#8805;Bi ならば、 Ci=Ai−borrowi−Bi ， borrowi+1=0とする。
		// 　　3.2. Ai−borrowi<Bi ならば、 Ci=Ai−borrowi+10−Bi ， borrowi+1=1とする。
		if (n == MAX_N) {
			return c;
		} else {
			if (ai - bor >= bi) {
				int ci = ai - bor - bi;
				res = solve(n + 1, a / 10, b / 10, c + pow10[n] * ci, f, 0);
			} else {
				int ci = ai - bor + 10 - bi;
				if (f < k) {
					res = Math.max(
							solve(n + 1, a / 10, b / 10, c + pow10[n] * ci, f,
									1),
							solve(n + 1, a / 10, b / 10, c + pow10[n] * ci,
									f + 1, 0));
				} else {
					res = solve(n + 1, a / 10, b / 10, c + pow10[n] * ci, f, 1);
				}
			}
		}
		return res;
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
//#include<cstdio>
//#include<cstdlib>
#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>
//#include<bitset>
//#include<string>
//#include<stack>
//#include<set>
//#include<unordered_set>
//#include<map>
//#include<unordered_map>
//#include<cstring>
//#include<complex>
//#include<cmath>
//#include<iomanip>
//#include<numeric>
#include <algorithm>
#include <stdio.h>
//#include<list>
//#include<functional>
//#include<cassert>
using namespace std;
#define ll long long int
#define llu unsigned long long int
void pv(vector<ll> arr, ll size)
{

    for (ll i = 0; i < size; i++)
    {
        cout << arr[i] << ' ';
    }
}
void gv(vector<double> &arr)
{
    ll size = arr.size();
    for (ll i = 0; i < size; i++)
    {
        cin >> arr[i];
    }
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;

    vector<double> a(n);
    gv(a);
    double arr[n + 1][n + 1] = {0};
    arr[0][0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 0; j <= i; j++)
        {
            if (j != 0)
                arr[i][j] = arr[i - 1][j] * (1 - a[i - 1]) + arr[i - 1][j - 1] * a[i - 1];
            else
            {
                arr[i][j] = arr[i - 1][j] * (1 - a[i - 1]);
            }
        }
    }
    double ans = 0;
    for (ll i = 0; i <= n; i++)
    {
        if (i > n / 2)
            ans += arr[n][i];
    }
    cout << setprecision(14) << ans;
    return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
#define endl "\n"
#define vi vector<int>
using namespace std;
int main()
{ 
   int k,a,b;
   cin>>k>>a>>b;
   for(int i=a;i<=b;i++)
   {
       if(i % k == 0)
       {
           cout<<"OK";
           exit(0);
       }
   }
    cout<<"NG";
}



Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;

int pip[200050];

struct edge
{
	int nxt,v;
}e[400050];

int head[200050],ecnt;

void adde(int u,int v)
{
	e[++ ecnt].v = v;
	e[ecnt].nxt = head[u];
	head[u] = ecnt;
}

void dfs(int pos,int lst)
{
	for(int i = head[pos];i;i = e[i].nxt)
	{
		int v = e[i].v;
		if(v != lst)
			dfs(v,pos);
	}
	if(!pip[pos])
	{
		if(pip[lst])
		{
			printf("First\n");
			exit(0);
		}
		pip[lst] = 1;
		pip[pos] = 1;
	}
}

int main()
{
	int n; scanf("%d",&n);
	for(int i = 1;i < n; ++ i)
	{
		int u,v; scanf("%d%d",&u,&v);
		adde(u,v),adde(v,u);
	}
	pip[0] = 1;
	dfs(1,0);
	printf("Second\n");
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int dp[maxn];
int main(){
	int n,k;
	int h[maxn];
	scanf("%d%d",&n,&k);
	for(int i = 1;i <= n;i++)
		scanf("%d",&h[i]);
	memset(dp,0x3f3f,sizeof(dp));
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= k;j++){
			if(i - j > 0){
				dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
			}
			else break;
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<ll, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}


int main() {
    ll a, b, n;
    cin >> a >> b;
    n = b - a + 1;
    if (a > 0 && b > 0) puts("Positive");
    else if (a < 0 && b < 0) {
        if (n & 1) puts("Negative");
        else puts("Positive");
    } else puts("Zero");
    return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a, b;
    cin >> a >> b;
    int ans = ceil((b - 1) * 1.0 / (a - 1));
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"
#define ll long long
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define pb push_back
#define pb2 pop_back
#define ff first
#define ss second
#define debug(x) cout<<#x<<" : "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define IO ios_base::sync_with_stdio(0);cin.tie(NULL);
const char nl = '\n';
ll cnt[10000001];
int main(){
    ll n,ans=0;cin>>n;
    for(ll i=1;i<=n;i++){
        for(ll j=0;(j+=i)<=n;){
            ++cnt[j];
        }
    }
    for(ll i=1;i<=n;i++){
        ans+=(i*cnt[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 81744
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    string N;
    cin >> N;
    if(N[0] == N[1] && N[1] == N[2]) cout << "Yes" << endl;
    else if(N[1] == N[2] && N[2] == N[3])cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iomanip>
#include <iostream>
using namespace std;
int main(){
    long double a,b,ans=0;
    cout<<fixed<<setprecision(9);
    cin>>a>>b;
    b*=1e2;
    for(long double i=1e2;i<=a*1e2;i+=1e2){
        long double sum=i,num=0;
        if(i>=b){
            ans+=1e4/a;
            continue;
        }
        while(sum<b){
            sum*=2;
            num+=1e2;
        }
        sum=1;
        while(num){
            sum*=2;
            num-=1e2;
        }
        ans+=(1e2/a)*(1e2/sum);
    }
    cout<<ans/1e4<<endl;
}

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

int main(void){
	int N, M, C;
	cin >> N >> M >> C;
	int A[N][M];
	int B[M];
	rep(i,M) cin >> B[i];
	rep(i,N)rep(j,M) cin >> A[i][j];

	int ans = 0;
	rep(i,N){
		int score = C;
		rep(j,M) score += A[i][j]*B[j];
		if (score > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

int rec(int level, int n, int a)
{
	if(level==n)
	{
		return a;
	}

	rec(level+1, n, a);
	for(int i = a+1; i<=n; i++)
	{
		rec(level+1, n, a+1);
	}
	// ans.pb()
	// rec(level+1, n, a+1);
}

int best = imn;
int q, m, n;
int rec_fn(int i, int pivot, vector<int>& arr, vector<vector<int> >& mat)
{
	if(i==n+1)
	{
		int sum = 0;
		for(int k = 0; k < q; k++)
		{
			if(arr[mat[k][1]-1]-arr[mat[k][0]-1]==mat[k][2])
				sum+=mat[k][3];
		}
		best = max(best, sum);
		return best;
	}

	for(int j = pivot; j<=m; j++)
	{
		arr[i]=j;
		best = rec_fn(i+1, j, arr, mat);
		// best = max(rec_fn(i+1, j, arr, mat), best);
	}
	return best;

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll sum = 0, maxim = 0;
	cin>>n>>m>>q;
	vector<vector<int> > mat(q+1, vector<int> (4));
	vector<int> ans(n+1, imx);
	for(int i = 0; i < q; i++)
		for(int j = 0; j < 4; j++)
			cin>>mat[i][j];
	int an = rec_fn(0, 1, ans, mat);
	p(an);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
     
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
     
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e18;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main(){
  string s;
  cin >> s;
  int n = s.size(), i, j;
  vl sum(n + 1);
  for (i = 0; i < n; i++){
    sum[i + 1] = sum[i] ^ (1 << (s[i] - 'a'));
  }
  vl x(27);
  x[1] = 1;
  for(i = 1; i < 26; i++){
    x[i + 1] = 2 * x[i];
  }
  vi dp((1 << 26), inf);
  dp[0] = 0;
  for(i = 1; i <= n; i++){
    //cout << i << endl;
    int m = inf + 2;
    for(j = 0; j < 27; j++){
      //cout<<j<<": ";
      //cout<<dp[x[j] ^ sum[i]]<<endl;
      m = min(m, dp[x[j] ^ sum[i]]);
    }
    //cout << m + 1 << endl << endl;
    dp[sum[i]] = min(dp[sum[i]], m + 1);
  }
  if (dp[sum[n]])
    cout << dp[sum[n]] << endl;
  else
    cout << 1 << endl;
}


Measured memory_bytes: 264324
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int i;

int p[15];

int comb(int n, int p) {
    if (n == 0 || n < p) {
        return 0;
    }
    double result = 1;
    for (i=0; i<p; i++) {
        result *= double((n-i)) / double((i+1));
    }
    return int(round(result));
}

int main(void) {
    int N;
    int cnt_2 = 0;
    int cnt_4 = 0;
    int cnt_14 = 0;
    int cnt_24 = 0;
    int cnt_74 = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    
    cin >> N;
    
    p[0] = N/2 + N/4 + N/8 + N/16 + N/32 + N/64;
    p[1] = N/3 + N/9 + N/27 + N/81;
    p[2] = N/5 + N/25;
    p[3] = N/7 + N/49;
    p[4] = N/11;
    p[5] = N/13;
    p[6] = N/17;
    p[7] = N/19;
    p[8] = N/23;
    p[9] = N/29;
    p[10] = N/31;
    p[11] = N/37;
    p[12] = N/41;
    p[13] = N/43;
    p[14] = N/47;
    
    for (i=0; i<15; i++) {
        if (p[i] >= 2) {
            cnt_2++;
        }
    }
    for (i=0; i<15; i++) {
        if (p[i] >= 4) {
            cnt_4++;
        }
    }
    for (i=0; i<15; i++) {
        if (p[i] >= 14) {
            cnt_14++;
        }
    }
    for (i=0; i<15; i++) {
        if (p[i] >= 24) {
            cnt_24++;
        }
    }
    for (i=0; i<15; i++) {
        if (p[i] >= 74) {
            cnt_74++;
        }
    }
    
    a = comb(cnt_4, 2) * (cnt_2 - 2);
    b = cnt_14 * (cnt_4 - 1);
    c = cnt_24 * (cnt_2 - 1);
    d = cnt_74;

    
    cout << a + b + c + d << endl;
    
    return 0;
}


Measured memory_bytes: 256
//
//  gacha.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll mod = 1000000007;


int main(int argc, const char* argv[]) {

  int n;
  std::cin >> n;
  std::map<std::string, int> ma;

  for (int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    ma[s] = i;
  }
  std::cout << ma.size() << std::endl;

  return 0;
}


Measured memory_bytes: 19260
#include <iostream>
#include <map>
#include <cmath>
using namespace std;

int euclid(int x, int y){
	int t;
	while (x % y){
		x %= y;
		t = x;
		x = y;
		y = t;
	}
	return y;
}
int main(){
	int p, q, n, m, t = 2, ans = 1;
	cin >> p >> q;
	n = q / euclid(p, q);
	m = n;
	map<int, int> f;
	while (n > 1 && t < sqrt(m) + 1){
		if (! (n % t)){
			n /= t;
			f[t] = 1;
		}
		while (! (n % t)){
			++f[t];
			n /= t;
		}
		++t;
	}
	if (n != 1) f[n] = 1;

	for (auto itr = f.begin(); itr != f.end(); ++itr){
		ans *= itr->first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 100010
struct node{
	int x,id;
	bool operator<(const node &a) const{
		return x<a.x;
	}
	node(int x=0,int id=0):x(x),id(id){}
}P[N<<1];
bool vis[N];
int n,x,y,M1=0,M2=0,tot=0;
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++){
		scanf("%lld%lld",&x,&y);
		M1+=x; M2+=y;
		P[++tot]=node(x,i);
		P[++tot]=node(y,i);
	}
	sort(P+1,P+1+tot);
	bool flag=0; int Mn=0;
	for (int i=1;i<=n;i++){
		Mn+=P[i].x;
		if (vis[P[i].id]) flag=1;
		vis[P[i].id]=1;
	}
	if (!flag) {
		if (P[n+1].id==P[n].id) Mn=min(Mn-P[n].x+P[n+2].x,Mn-P[n-1].x+P[n+1].x);
		else Mn=Mn-P[n].x+P[n+1].x;
	}
	printf("%lld\n",min(min(Mn,M1),M2));
	return 0;
}


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

using ll = long long;

int main(){
  int N;
  cin >> N;

  vector<vector<int>> a(N, vector<int>(3, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }

  vector<vector<int>> dp(100100, vector<int>(3, 0));

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j==k) continue;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j]+a[i][k]);
      }
    }
  }

  int ans=0;

  for (int i = 0; i < 3; i++) {
    ans = max(ans, dp[N][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String[] S = new String[101];
		String[] ss = new String[N];
		int[] P = new int[101];
		for( int i=0; i<N; i++ ){
			String str = sc.next();
			int a = sc.nextInt();
			S[a] = str;
			P[a] = i+1;
			ss[i] = str;
		}
		Arrays.sort(ss);
		for( int i=0; i<N; i++ ){
			for( int k=100; k>=0; k-- ){
				if( ss[i].equals(S[k]) && !(S[k].equals("A")) ){
					S[k] = "A";
					System.out.println(P[k]);
					break;
				}
			}			
		}
	}
}


Measured memory_bytes: 23764
#!/usr/bin/env python3

S = input()
N = len(S)

S_1 = S[:((N-1)//2)]
S_2 = S[((N+3)//2)-1:N]

if S == S[::-1] and S_1 == S_1[::-1] and S_2 == S_2[::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    double N;
    cin>>N;
    rep(x,N+1){
        if((int)((double)x * 1.08) == N){
            cout<<x<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}

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

int main(){
  int n = 1;
  int x = 1;
  while(!(n == 0 && x == 0)){
    cin >> n >> x;
    int ans = 0;
    if(n == 0 && x == 0) break;
    rep(i, n-2){
      for(int j=i+1; j<n-1; j++){
        for(int k=j+1; k<n; k++){
          if(i+j+k+3 == x) ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3104
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string a,b,c; cin>>a>>b>>c;
    cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
}

Measured memory_bytes: 256
K = int(input())

c = 0
for i in range(1, K):
  for j in range(i+1, K+1):
    if i%2 == 0 and j%2 == 1:
     	c += 1
    if i%2 == 1 and j%2 == 0:
      	c += 1
print (c)

Measured memory_bytes: 2940
input = ["", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
n = gets.to_i
n.times{
    str = gets.chomp.split("").map(&:to_i)
    k, c = 0, 0
    str.each{|x|
        if x == 0
            print input[k][c % input[k].length] if k != 0
        elsif x == k
            c += 1
        else
            c = 0
        end
        k = x
    }
    puts
}



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

int main(void) {
  string s,t;
  cin >> s >> t;

  int cnt = 0;

  int n = s.size();
  for(int i = 0; i < n; i++) {
    if(s.at(i) != t.at(i)) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3900
def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    x = N - K + 1
    ans = [x]
    for i in range(2, K + 1):
        x = ((x * (N - K + 2 - i) * (K - i + 1) // (i * (i - 1))))
        ans.append(x % MOD)
    print ('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	string s;
	cin>>s;
	if(s.substr(0, 4)=="YAKI")cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
S = gets.chomp
K = gets.chomp.to_i

a = [0] * 5

s2 = S * 5

0.upto(s2.size - 2) do |i|
  next unless s2[i] == s2[i + 1]
  s2[i + 1] = '1'
  a[(i + 1) / S.size] += 1 
end

ans = a[0]
ans += a[1] if K >= 2
ans += a[2] * (((K - 2) + 1) / 2) if K >= 3
ans += a[3] * ((K - 2) / 2) if K >= 4

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=400005;

int S[maxn];
int n,q;

void update(int id,int i,int v,int l,int r) {
	if (l==r) S[id]+=v;
	else {
		int m=l+r>>1;
		if (i<=m) update(id<<1,i,v,l,m);
		else update(id<<1|1,i,v,m+1,r);
		S[id]=S[id<<1]+S[id<<1|1];
	}
}

int query(int id,int ql,int qr,int l,int r) {
	if (ql==l && qr==r) return S[id];
	int m=l+r>>1;
	if (qr<=m) return query(id<<1,ql,qr,l,m);
	else if (ql>m) return query(id<<1|1,ql,qr,m+1,r);
	else return query(id<<1,ql,m,l,m)+query(id<<1|1,m+1,qr,m+1,r);
}

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		if (op) {
			int s,t; cin>>s>>t;
			cout<<query(1,s,t,1,n)<<'\n';
		}
		else {
			int i,x; cin>>i>>x;
			update(1,i,x,1,n);
		}
	}
}


Measured memory_bytes: 4144
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

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


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

  string s;
  cin >> s;

  bool good = true;
  for(int i = 0; i + 1 < s.length(); i++){
    if(s[i] == s[i + 1]){
      good = false;
      break;
    }
  }

  if(good) cout << "Good" << endl;
  else cout << "Bad" << endl;

  return 0;
}


Measured memory_bytes: 760
def main():
    import sys
    import math
    import collections
    import itertools

    input = sys.stdin.readline().rstrip

    n = int(input())
    ans_ab = (1, n)
    for i in range(2, int(math.sqrt(n) + 1)):
        if n % i == 0:
            ans_ab = (i, n // i)

    print(len(str(ans_ab[1])))
    
if __name__ == '__main__':
    main()

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


int main()
{
	long long n, a[10001], s;
	for(int i=0; i<10001; i++)
	{
		a[i]=0;
	}
	cin >> n;
	for(long long i=1; i<100; i++)
	{
		for(long long j=1; j<100; j++)
		{
			for(long long k=1; k<100; k++)
			{
				s=i*i+j*i+k*i+j*j+j*k+k*k;
				if(s<10001 && s>0)
				{
					a[s]++;
				}
			}
		}
	}
	for(long long i=1; i<=n; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
double rad;
double PI = acos(-1);
int main()
{
  int a, b, C;
  cin >> a >> b >> C;
  rad = C * PI / 180;
  double c = sqrt(a * a + b * b - 2 * a * b * cos(rad));
  double S = (a * b * sin(rad)) / 2;
  printf("%.8lf\n", S);
  printf("%.8lf\n", (a + b + c));
  double h = (2 * S) / a;
  printf("%.8lf\n", h);
}



Measured memory_bytes: 3376
import java.util.Scanner;

public class Main {

	private static long f(long x) {
		int a = 0;
		while (x % 2 == 0) {
			x /= 2;
			a++;
		}
		return a;
	}

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

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		long m = sc.nextLong();
		long[] a = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			if (a[i] % 2 == 1) {
				System.out.println(0);
				return;
			}
			a[i] /= 2;
		}

		long t = f(a[0]);
		for (int i = 0; i < n; i++) {
			if (f(a[i]) != t) {
				System.out.println(0);
				return;
			}
			a[i] >>= t;
		}
		m >>= t;

		long b = 1;
		for (int i = 0; i < n; i++) {
			b = lcm(b, a[i]);
			if (b > m) {
				System.out.println(0);
				return;
			}
		}

		m /= b;
		System.out.println((m + 1) / 2);
	}
}


Measured memory_bytes: 60452
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
  int a, p;
  scanf("%d %d", &a, &p);

  printf("%d\n", (3 * a + p) / 2);
  return 0;
}


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

int64_t comper(string &S, int h, int low) {
  if (h >= low) {
    return 0;
  }
  else if (low - h == 1) {
    return S.at(h) - '0';
  }
  else {
    return comper(S, h+1, low) + (S.at(h) - '0') * pow(10, low - h - 1);
  }
}
    

int main() {
  string S;
  cin >> S;
  int sz = S.size();
  int low, h;
  vector<vector<int64_t>> ncat(sz, vector<int64_t>(sz + 1));
  int64_t ans = 0;
  for (h=0; h < sz; h++){
    for (low=h+1; low < sz + 1; low++) {
      ncat.at(h).at(low) = comper(S, h, low);
      if (h == 0 && low == sz)  ans += ncat.at(h).at(low);
      else if (h == 0 && low != sz)  ans += pow(2, sz - low - 1) * ncat.at(h).at(low);
      else if (h != 0 && low == sz)  ans += pow(2, h - 0 - 1) * ncat.at(h).at(low);
      else  ans += pow(2, sz - low - 1) * pow(2, h - 0 - 1) * ncat.at(h).at(low);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
class Node():
    def __init__(self, key):
        self.key = key
        self.left = self.right = None
        
def insert(key):
    global root

    x = root
    y = None
    while x:x, y = x.left if key < x.key else x.right , x
    if y == None:root = Node(key)
    elif y.key < key:y.right = Node(key)
    else:y.left = Node(key)
        
        
def pre(node):
    if node == None:return
    print('',node.key, end = '');pre(node.left);pre(node.right)
    
def ino(node):
    if node == None:return
    ino(node.left);print('',node.key,end='');ino(node.right)


n = int(input())
root = None
for j in range(n):
    s, *i = input().split()
    if s[0] == 'i':insert(int(i[0]))
    else:
        ino(root);print('');pre(root);print()
        
    


Measured memory_bytes: 105424
N, T = gets.split.map &:to_i
PRICES = gets.split.map &:to_i

diff = 0
n_pairs = 0
m = PRICES[0]

PRICES.drop(1).each do |c|
  newdiff = c - m
  if diff < newdiff
    diff = newdiff
    n_pairs = 1
  elsif diff == newdiff
    n_pairs += 1
  end
  m = [m, c].min
  #p c: c, diff: diff, m: m 
end
p n_pairs


Measured memory_bytes: 11012
#include<bits/stdc++.h>
using namespace std;
main()
{
    float a,b,c,d,f,g;
    cin>>a>>b>>c;
    d=a/c;
    if(d<=b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    for(int i = 0; i < n-1; i++){
        if(vec.at(i) == vec.at(i+1)){
            vec.at(i) = 0;
            vec.at(i+1) = 0;
        }
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        if(vec.at(i) != 0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var xyh = new (long x, long y, long h)[N];
            for (var i = 0; i < N; ++i)
                xyh[i] = Slice3<long>();
            var b = xyh.First(o => 0 < o.h);
            for (var x = 0; x <= 100; ++x)
                for (var y = 0; y <= 100; ++y)
                {
                    var H = b.h + Abs(b.x - x) + Abs(b.y - y);
                    if (H < 0) continue;
                    if (xyh.All(o => o.h == Max(H - Abs(o.x - x) - Abs(o.y - y), 0)))
                    {
                        WriteLine($"{x} {y} {H}");
                        return;
                    }
                }
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 29484
# coding: utf-8

H, W = map(int, input().split())

if H ==1 or W == 1:
    print(1)
else:
    h_even= H//2
    h_odd= H-h_even
    w_even= W//2
    w_odd= W-w_even


    # if H%2 == 1:
    #     r1=r+1
    #     print(r*W//2+r1*(W-W//2))
    # else:
    #     print(r*W//2+r*(W-W//2))

    # if H%2==1 or W%2==1:
    #     print(h_odd*w_odd+h_even*w_even-1)
    # else:
    #     print(h_odd*w_odd+h_even*w_even)
    print(h_odd*w_odd+h_even*w_even)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

int main() {
  string s; cin >> s;

  int ans = 0;
  rep(i, s.length()/2) {
    int r = s.length()-(i+1);
    if (s[i] != s[r]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
#define INF 1e14
typedef long long int ll;
const ll N=1e5+5;
bool x[N+1]={false};
ll fast(ll n,ll a)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a)%Mod;
        if(n%2==0)
        {
            return (((res%Mod)*(res%Mod))%Mod);
        }
        else{
            return (((((res%Mod)*a)%Mod)*res)%Mod);
        }
    }
}

int main()
{
  ll n;
  cin>>n;
  ll res,tes;
  if(n%2==0)
  {
      res=n/2;
      tes=n-1;
  }
  else
  {
      res=(n-1)/2;
      tes=n;
  }
  cout<<tes*res;




}


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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 2e15+7;
const ll mod = 1e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = int> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

bool UnionFind::same(int x,int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

int main() {
	int n=in(),m=in();
	ll x[n],y[m],difx[n],dify[m];
	difx[0]=dify[0]=0;
	ll xsum,ysum=xsum=0;
	ll cnt=n-1;
	REP(i,n){x[i]=in();if(i)difx[i]=x[i]-x[i-1];}
	REP(i,m){y[i]=in();if(i)dify[i]=y[i]-y[i-1];}
	FOR(i,1,n){
		xsum=(xsum+difx[i]*cnt%mod)%mod;
		cnt=cnt-i*2+n-1;
	}
	cnt=m-1;
	FOR(i,1,m){
		ysum=(ysum+dify[i]*cnt%mod)%mod;
		cnt=cnt-i*2+m-1;
	}
	cout << xsum*ysum%mod << endl;
}

Measured memory_bytes: 3328
N, K, Q = map(int,input().split())
A=[]
P=[]
for i in range(Q):
    A.append(int(input())-1)
for j in range(N):
    P.append(K-Q)
for k in A:
    P[k]+=1
for l in range(N):
    print('Yes' if P[l]>0 else 'No')

Measured memory_bytes: 11768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <string>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
    return 0;
}

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

int main() {
  int N;
  string S;
  string ans = "Three"; //3種類の場合で初期化
  cin >> N;
  
  for (int i=0;i<N;i++) {
    cin >> S;
    if (S=="Y") {
      //黄色が見つかったら4種類で確定
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def lcs(s1, s2):

    dp = []

    for s2_k in s2:

        bgn_idx = 0

        for i, cur_idx in enumerate(dp):

            chr_idx = s1.find(s2_k, bgn_idx) + 1

            if not chr_idx:

                break

            dp[i] = min(cur_idx, chr_idx)

            bgn_idx = cur_idx

        else:

            chr_idx = s1.find(s2_k, bgn_idx) + 1

            if chr_idx:

                dp.append(chr_idx)

    return len(dp)



def solve():

    N = int(input())

    for _ in range(N):

        x = input()

        y = input()

        print(lcs(x, y))



if __name__ == '__main__':

    solve()


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  string a[n],b[m];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int j=0;j<m;j++)cin>>b[j];
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      int c=1;
      for(int k=i;k<i+m;k++){
        for(int l=j;l<j+m;l++){
          if(a[k][l]!=b[k-i][l-j]){
            c=0;
            break;
          }
        }
        if(c==0)break;
        
      }
      if(c==1){
        cout<<"Yes"<<endl;
        return 0;
      }
      
    }
  }
  cout<<"No"<<endl;
}


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


// v[1]がルート
struct SegmentTree {
	vector<ll> v;
	int ofs;
	SegmentTree( int n ) {
		for ( ofs = 1; ofs < n; ofs *= 2 )
			;
		v = vector<ll>(ofs*2,LLONG_MAX);
	}
	
	// v[node] は 区間 l .. r-1 全体が同じ値なら、その値を持つ
	
	// 区間[l..r-1] の値をvalにする。oldvalがある場合は、[l..r-1]以外の部分をoldvalにする。
	void range_update2( int begin, int end, int node, int l, int r, ll val, ll oldval ){
		if ( end <= l || r <= begin ){
			if ( oldval != LLONG_MAX )
				v[node] = oldval;
			return;
		}
		if ( begin <= l && r <= end ){
			v[node] = val;
			return;
		}
		else {
			if ( oldval == LLONG_MAX && v[node] != LLONG_MAX ){
				oldval = v[node];
			}
			v[node] = LLONG_MAX; // この区間は、もはや一様ではない
			range_update2( begin, end, node*2,   l,       (l+r)/2, val, oldval );
			range_update2( begin, end, node*2+1, (l+r)/2, r      , val, oldval );
		}
	}
	
	//  begin .. end-1 の区間
	void range_update( int begin, int end, ll val ){
		return range_update2( begin, end, 1, 0, ofs, val, LLONG_MAX );
	}
	
	
	ll get( int i ){
		i += ofs;
		ll val = v[i];
		i /= 2;
		
		while ( i ){
			if ( v[i] != LLONG_MAX )
				val = v[i];
			i /= 2;
		}
		return val;
	}
};


/*
  区間update
  座標を番号に
*/

ll N, Q;


struct kouji{
	ll S, T, X;
	ll t0, t1;
};

vector<kouji> k;

struct walker{
	ll D;
	ll t;
};
vector<walker> w;

int main(){
	cin >> N >> Q;
	k.resize(N);
	
	vector<ll> renum;
	renum.reserve(N*2+Q);
	
	for ( int i = 0; i < N; i++ ){
		cin >> k[i].S >> k[i].T >> k[i].X;
		renum.push_back(k[i].S-k[i].X);
		renum.push_back(k[i].T-k[i].X);
	}
	
	w.resize(Q);
	for ( int i = 0; i < Q; i++ ){
		cin >> w[i].D;
		renum.push_back(w[i].D);
	}
	
	
	// 座標を番号にする
	sort(renum.begin(),renum.end());
	
	auto f = [&](ll z){
		auto it = lower_bound(renum.begin(), renum.end(), z);
		return it - renum.begin();
	};
	for ( int i = 0; i < N; i++ ){
		k[i].t0 = f(k[i].S-k[i].X);
		k[i].t1 = f(k[i].T-k[i].X);
	}
	for ( int i = 0; i < Q; i++ ){
		w[i].t = f(w[i].D);
	}
	
	// 工事を登録する。Xが大きいものから順に上書きする
	SegmentTree seg(renum.size());
	sort(k.begin(), k.end(), [](const kouji &l, const kouji &r){return l.X < r.X;});
	for ( int i = N-1; i >= 0; i-- ){
		seg.range_update(k[i].t0, k[i].t1, k[i].X);
		
		//cout << k[i].t0 << "/" << k[i].t1 << "/" << k[i].X << endl;
		//for ( int j = 0; j < renum.size(); j++ ){
		//	cout << j << "->" << seg.get(j) << endl;
		//}
	}
	
	
	// query
	for ( int i = 0; i < Q; i++ ){
		ll x = seg.get(w[i].t);
		if ( x == LLONG_MAX )
			x = -1;
		cout << x << endl;
	}
	
	return 0;
}



Measured memory_bytes: 33920