akhauriyash/Code-Regression huggingface dataset:
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll X; cin >> X;
  ll n = 6;
  vector<ll> v{100,101,102,103,104,105};
  vector<vector<bool>> dp(n+1, vector<bool>(X+1, false));
  dp[0][0] = true;
  rep(i, n) rep(j, X+1) {
    if (!dp[i][j]) continue;
    ll nj = j + v[i];
    if (nj <= X) dp[i][nj] = true;
    dp[i+1][j] = true;
  }
  if (dp[n][X]) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   int a;
   cin >> a;
   cout << a+a*a+a*a*a << endl;   
   return 0;
}


Measured memory_bytes: 3632
//long time no ac
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());
#define N 100005


ll a[N][3],dp[N][3],n;

ll f(ll x,ll l)
{
	if(x>n-1) return 0;
	if(dp[x][l]==-1)
	{
		dp[x][l]=0;
		rep(i,3)
		{
			// debug3(x,l,dp[x][l]);
			if(i==l && x!=0) continue;
			dp[x][l]=max(dp[x][l],a[x][i]+f(x+1,i));
		}
	}
	return dp[x][l];
}

int main()
{
	SPEED;
	ll k,t,j,m,cs=0;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		// ll a[n];
		rep(i,n)
		{
			cin>>a[i][0]>>a[i][1]>>a[i][2];
		}
		memset(dp,-1,sizeof(dp));
		cout<<f(0,0);
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N; cin >> N ;
  vector<ll> a; 
  rep(i,N){
    ll inp; cin >> inp;
    a.pb(inp);
  }
  sort(all(a));
  cout << a[a.size()-1] - a[0] << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var pqr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(pqr.Sum() - pqr.Max());
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){

        string w,t;
        int sum = 0;
        cin >> w;
        std::transform(w.begin(), w.end(), w.begin(), ::toupper);
        while(cin >> t){
                if(t == "END_OF_TEXT") break;
                transform(t.begin(), t.end(), t.begin(), ::toupper);
                if(w.compare(t) == 0)sum++;
        }

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

Measured memory_bytes: 1192
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	int a, b;
	cin >> a >> a >> b >> b;
	cout << (b == 1) << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
k = ''
for i in range(H):
    s = list(input().split())
    if s.count('snuke')>0:
        k = alp[s.index('snuke')]+str(i+1)
print(k)

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

int main(){
	int W, H, N;
	cin >> W >> H >> N;
	int S[H][W], x, y, a, c=0, i, j, k;
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			S[i][j]=1;
		}
	} 
	for(k=0; k<N; k++){
		cin >> x >> y >> a;
		if(a==1){
			for(i=0; i<H; i++){
				for(j=0; j<x; j++){
					S[i][j]=0;
				}
			}
		} else if(a==2){
			for(i=0; i<H; i++){
				for(j=x; j<W; j++){
					S[i][j]=0;
				}
			}
		} else if(a==3){
			for(i=0; i<y; i++){
				for(j=0; j<W; j++){
					S[i][j]=0;
				}
			}
		} else if(a==4){
			for(i=y; i<H; i++){
				for(j=0; j<W; j++){
					S[i][j]=0;
				}
			}
		}
	}
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			c += S[i][j];
		}
	}
	cout << c;
}

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

int main(){
    ll INF = 1e10;
    ll n,m,k;
    cin >> n >> m >> k;
    ve<ll> a(n), b(m);
    ve<ll> sa(n+1,INF), sb(m+1,INF);
    sa[0] = 0;
    sb[0] = 0;
    rep(i,n){
        cin >> a[i];
        sa[i+1] = min(sa[i+1],sa[i]+a[i]);
    }
    rep(i,m){
        cin >> b[i];
        sb[i+1] = min(sb[i+1],sb[i]+b[i]);
    }
    ll ans = 0;
    rep(i,n+1){
        if(sa[i]>k)break;
        ll j = upper_bound(sb.begin(), sb.end(), k-sa[i])-sb.begin();
        j--;
        ans = max(ans,i+j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int a[200005],mod=1e9+7;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    FOR(i,1,n)cin>>a[i];
    int ans=0;
	sort(a+1,a+n+1,greater<int>());
	FOR(i,1,n)ans=ans+a[i]*(i+1),ans=ans%mod;
	FOR(i,1,2*n-2){
    	ans=ans*2%mod;
	}
	cout<<ans;
    return 0;
}




Measured memory_bytes: 1792
/*
    Vora Mahammadasim
*/

#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<a*b<<'\n';
}


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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const int MAXN = 5010;

int mod;

inline int Mod(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y, x -= x >= mod ? mod : 0; }

int f[MAXN][MAXN];
int g[MAXN][MAXN];
int S[MAXN * 2];

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri; mod = ri;
	int N = (n + 1) / 2;

	f[0][0] = 1;
	for(int i = 1; i <= N; i++)
		for(int j = 0; j <= n; j++)
			for(int k = j; k <= n; k += i)
				Add(f[i][k], f[i - 1][j]);

	g[0][0] = 1;
	for(int i = N - 1; i >= 1; i--) {
		for(int j = 0; j <= n; j++) {
			if(i * j >= n) break;
			for(int k = i * j; i + k <= n; k++)
				if(i + k <= n)
					Add(g[j + 1][k + i], g[j][k]);
		}
	}

	for(int i = 0; i <= n; i++)
		for(int j = 1; j <= n; j++)
			Add(g[i][j], g[i][j - 1]);
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= n; j++)
			Add(g[i][j], g[i - 1][j]);

	int n1 = N, n2 = N - 1;
	int res = 0;
	if(!(n & 1)) {
		for(int x = 1; x <= n; x++)
			for(int i = 0; i < x; i++)
				res = (res + 1LL * f[n1][i] * g[n - x][x - i - 1]) % mod;
	} else {
		for(int x = 1; x <= n; x++)
			for(int i = 0; i < x; i++)
				res = (res + 1LL * f[n1 - 1][i] * g[n - x][x - i - 1]) % mod;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 147712
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    x1,y1,x2,y2 = I2()
    v = x2 - x1#x
    w = y2 - y1#y
    print(x2-w,y2+v,x1-w,y1+v)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,a,b;
  cin >> x >> a >> b;
  int y = a-b;
  if (y >= 0) {
    cout << "delicious" << endl;
  } else if (b-a <= x) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <stack>
using namespace std; 
int sign[100010]; 
vector<int> E[100010] = {}; 
int pos = 0; int neg = 0; 
int N, M; 
bool possible = true; 
void dfs(int a, int pm){
	sign[a] = pm; 
	int s = E[a].size(); 
	for(int i = 0; i < s; i++){
		if(sign[E[a].at(i)] == pm) {possible = false; return;}
		else if(sign[E[a].at(i)] == -pm) continue; 
		else{
			dfs(E[a].at(i), -pm); 
		}
	}
	return; 
}
int main(){
	cin >> N >> M; 
	for(int i = 0; i < M; i++){
		int a, b; 
		cin >> a >> b; 
		E[a].push_back(b); 
		E[b].push_back(a); 
	}
  	dfs(1, 1); 
	if(!possible) cout << (long long) N * (N-1) / 2 - M << endl; 
	else{
		for(int i = 1; i <= N; i++){
			if(sign[i] > 0) pos ++; 
			else if(sign[i] < 0) neg ++; 
		}	 
		cout << (long long) pos * neg - M << endl; 
	}
}

Measured memory_bytes: 6912
n = int(input())
card = []
tc = []
hc = []

taro = 0
hanako = 0
counter = 0

i = 0
j = 0
k = 0
for i in range(n):
    card.append(list(input().split()))
    tc.append(list(card[i][0]))
    hc.append(list(card[i][1]))

    if len(card[i][0]) <= len(card[i][1]):
        counter = len(card[i][0])
    else:
        counter = len(card[i][1])
    
    for j in range(counter):
        if ord(tc[i][j].lower()) < ord(hc[i][j].lower()):
            hanako += 3
            break
        elif ord(tc[i][j].lower()) > ord(hc[i][j].lower()):
            taro += 3
            break
        else:
            if j == counter - 1:
                if len(card[i][0]) < len(card[i][1]):
                    hanako += 3
                elif len(card[i][0]) > len(card[i][1]):
                    taro += 3
                else:
                    taro += 1
                    hanako += 1

                break

print("%d %d" % (taro, hanako))



Measured memory_bytes: 5856
#include <stdio.h>

int tall_table[7][7] = {{   0,  300,  500,  600,  700, 1350, 1650},
                        { 300,    0,  350,  450,  600, 1150, 1500},
                        { 500,  350,    0,  250,  400, 1000, 1350},
                        { 600,  450,  250,    0,  250,  850, 1300},
                        { 700,  600,  400,  250,    0,  600, 1150},
                        {1350, 1150, 1000,  850,  600,    0,  500},
                        {1650, 1500, 1350, 1300, 1150,  500,    0}};

int km[7][7] ={{ 0,  6, 13, 18, 23, 43, 58},
               { 6,  0,  7, 12, 17, 37, 52},
               {13,  7,  0,  5, 10, 30, 45},
               {18, 12,  5,  0,  5, 25, 40},
               {23, 17, 10,  5,  0, 20, 35},
               {43, 37, 30, 25, 20,  0, 15},
               {58, 52, 45, 40, 35, 15,  0}};
               

int main(void)
{
    int start_ic, end_ic;
    int start_hr, start_min;
    int end_hr, end_min;
    int start_time, end_time;
    int tall;
    
    while (1){
        scanf("%d", &start_ic);
        if (start_ic == 0){
            break;
        }
        scanf("%d%d", &start_hr, &start_min);
        scanf("%d", &end_ic);
        scanf("%d%d", &end_hr, &end_min);
    
        start_time = start_hr * 100 + start_min;
        end_time = end_hr * 100 + end_min;
        
        tall = tall_table[start_ic - 1][end_ic - 1];
        
        if (km[start_ic - 1][end_ic - 1] <= 40){
            if (1730 <= start_time && start_time <= 1930 ||
                1730 <= end_time   && end_time   <= 1930){
            
                tall /= 2;
                tall = (tall + 49) / 50 * 50;
            }
        }
        
        printf("%d\n", tall);
    }
    return (0);
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int h ;int a;int c;int i;
    c=0;
    cin >>h>>a;
    for (i=0;i<10000;i++){
        if (h>0){
            h=h-a;
            c+=1;
        }

    }
    cout <<c;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int[] intheight  = new int[10];
		int[] intTopheight = new int[3];
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("\n");
		for(int i=0;i<10;i++){
			intheight[i] = scan.nextInt();
		}
		for(int i=0;i<10;i++){
			for(int j=0;j<3;j++){
				if(intTopheight[j]<=intheight[i]){
					if(j==0){
						intTopheight[2]=intTopheight[1];
						intTopheight[1]=intTopheight[0];
						intTopheight[0]=intheight[i];
					}
					if(j==1){
						intTopheight[2]=intTopheight[1];
						intTopheight[1]=intheight[i];
					}
					if(j==2){
						intTopheight[2]=intheight[i];
					}
					break;
				}
			}
		}
		for(int k=0;k<3;k++){
			System.out.println(intTopheight[k]);
		}
	}

}

Measured memory_bytes: 17168
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 1000;

typedef tuple<ll, int, int, int> tup;

int main() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	ll a[N], b[N], c[N];
	for(int i = 0; i < x; i++) cin >> a[i];
	for(int i = 0; i < y; i++) cin >> b[i];
	for(int i = 0; i < z; i++) cin >> c[i];
	sort(a, a + x, greater<ll>());
	sort(b, b + y, greater<ll>());
	sort(c, c + z, greater<ll>());

	vector<vector<vector<bool>>> f(x,
		vector<vector<bool>>(y,
			vector<bool>(z, false)));

	priority_queue<tup, vector<tup>> que;
	que.push(tup(a[0] + b[0] + c[0], 0, 0, 0));
	f[0][0][0] = true;

	while(k > 0) {
		tup t = que.top();
		que.pop();
		k--;
		cout << get<0>(t) << endl;
		int i = get<1>(t), j = get<2>(t), l = get<3>(t);
		if(i + 1 < x && !f[i + 1][j][l]) {
			que.push(tup(a[i + 1] + b[j] + c[l], i + 1, j, l));
			f[i + 1][j][l] = true;
		}
		if(j + 1 < y && !f[i][j + 1][l]) {
			que.push(tup(a[i] + b[j + 1] + c[l], i, j + 1, l));
			f[i][j + 1][l] = true;
		}
		if(l + 1 < z && !f[i][j][l + 1]) {
			que.push(tup(a[i] + b[j] + c[l + 1], i, j, l + 1));
			f[i][j][l + 1] = true;
		}
	}
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int H1, M1, H2, M2, K;
    cin>>H1>>M1>>H2>>M2 >> K;
    cout << (H2 - H1) * 60 + (M2- M1) -K << endl;
}

Measured memory_bytes: 3632
import sys
from collections import Counter

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

A_count = Counter(A)


allsum = 0

for i in (A_count.values()):
    allsum += (i*(i-1))//2


for j in A:
    counter_num = A_count[j]
    difference = (((counter_num)*(counter_num-1))//2) - (((counter_num-1)*(counter_num-2))//2)
    print(allsum - difference) 

Measured memory_bytes: 34060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    vector<ll> a(3);
    ll sum = 0;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        p[i] = t[0] - 'A';
        q[i] = t[1] - 'A';
    }
    vector<char> ans(n);
    for (int i = 0; i < n; i++) {
        if (a[p[i]] > a[q[i]]) {
            ans[i] = 'A' + q[i];
            a[p[i]]--;
            a[q[i]]++;
        } else if (a[q[i]] > a[p[i]] || sum != 2LL || i == n - 1) {
            ans[i] = 'A' + p[i];
            a[p[i]]++;
            a[q[i]]--;
        } else {
            if (p[i] == p[i + 1] || p[i] == q[i + 1]) {
                ans[i] = 'A' + p[i];
                a[p[i]]++;
                a[q[i]]--;
            } else {
                ans[i] = 'A' + q[i];
                a[p[i]]--;
                a[q[i]]++;
            }
        }
        for (int i = 0; i < 3; i++) {
            if (a[i] < 0) {
                cout << "No" << '\n';
                return 0;
            }
        }
    }
    cout << "Yes" << '\n';
    for (char c : ans) {
        cout << c << '\n';
    }
    return 0;
}

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

using namespace std;

int main(){
        int n;
        bool valid = false;
        cin >> n;
        for(int i = 1; i < 10; i++){
                for(int j = 1; j < 10; j++){
                          if(i*j == n){
                                valid = true;
                                break;
                          }

                }
                if(valid) break;
        }
        if(valid) cout << "Yes" << endl;
        else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
long long int A,B,C,c,d,e;
scanf("%lld %lld %lld",&A,&B,&C);
c=A*A;
d=B*B;
e=C*C;
if(c+d==e)
printf("%.lf\n",(.5*A*B));
else if(c+e==d)
printf("%.lf\n",(.5*A*B));
else if(d+e==c)
printf("%.lf\n",(.5*C*B));
return 0;
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int dp[100000];

void solve(){
     int t,k; 
     memset(dp, 0, sizeof dp);
   cin>>t;
   for(int i=0;i<t;++i){
       cin>>a[i];
   }
   //dp[0]=a[0];
      for(int i=1;i<t;++i){
          dp[i]=1000000000;
          for(int j=i-1;j>=0 && (i-j)<=2; j--){
              dp[i]=min(dp[i], abs(a[i]-a[j]) + dp[j]);
          }
      }

  cout<<dp[t-1]<<endl;
   
}
int main() {
  
   // while(t--){
    solve();
//   }
    return 0;
}


Measured memory_bytes: 4400
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Solve()
    {
        var N = ReadInt();
        var S = Read();
        var K = ReadInt();

        var ans = new char[N];
        var keep = S[K - 1];

        for(var i = 0; i< N; i++)
        {
            ans[i] = S[i] == keep ? keep : '*';
        }
        Console.WriteLine(ans);

    }

    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef unsigned long long ull;
typedef long long ll;
const int maxn = 3e5+5;
const int mod = 1e9+7;
using namespace std;
const ll MAX=9223372036854775807;

ll a[maxn];

int main()
{
	ll n;
	ll temp = 1e18, ans=1;
	//cout << tmp << '\n';
	int flag = 1;
	cin >> n;
	rep(i,0,n) {
		cin >> a[i];
		if (a[i]==0) flag=0;
	}
	if (!flag) {cout << "0\n"; return 0;}

	rep(i,0,n) {
		if (a[i] > MAX/ans || a[i]*ans > temp) {flag=0; break;}
		ans*=a[i];
	}
	if (!flag) cout << "-1\n";
	else cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 4404
#include <iostream>

using namespace std;

int main(int argc, char** argv){
    long long K;
    cin >> K;
    long long dividend = 7;
    for (long long i=1; i<=K+1; i++){
        if (dividend % K == 0){
            cout << i << "\n";
            return 0;
        }
        dividend = dividend * 10 % K;
        dividend = (dividend + 7) % K;
    }
    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
    int n;
    int i;
    int j;
    int k;
    int l;   
    int card[4][14] = {{}};
    cin >> n;
    char a;
    int b;
    for(i = 0;i < n;i++){
        cin >> a >> b;
        switch(a){
            case 'S':
                card[0][b-1] = 1;
                break;
            case 'H':
                card[1][b-1] = 1;
                break;
            case 'C':
                card[2][b-1] = 1;
                break;
            case 'D':
                card[3][b-1] = 1;
                break;
        }
    }
    for(i = 0;i < 52;i++){
        switch(i/13){
            case 0:
                if(card[0][i%13]==0) cout << "S " << i+1 << endl;
                break;
            case 1:
                if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
                break;
            case 2:
                if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
                break;
            case 3:
                if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
                break;
        }
    }
return 0;
}
    


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>

using namespace std;

int N;
int A[210];

int main() {
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    int res = 0;

    while(true) {
        bool exist_odd = false;
        for(int i = 0; i < N; i++) {
            if(A[i] % 2 != 0) exist_odd = true;
        }

        if(exist_odd) break;

        for(int i = 0; i < N; i++) {
            A[i] /= 2;
        }
        res++;
    }

    cout << res << endl;
    return 0;
}

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

signed main() {
  int N, A, B;
  cin >> N >> A >> B;

  if ((B - A) % 2 == 0) {
    cout << (A + B) / 2 - A << endl;
    return 0;
  }

  int L = abs(A - 1);
  if ((B - abs(A - 1)) == 2) {
    L++;
  } else {
    L += (B - abs(A - 1)) / 2;
  }

  int R = abs(N - B);
  if (A + abs(N - B) == N - 1) {
    R++;
  } else {
    R += (N + A + abs(N - B) + 1) / 2 - (A + abs(N - B));
  }

  cout << min(L, R) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    D,T,S = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if T>=D/S:
        print('Yes')
    else:
        print('No')
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 77504
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

type Element struct {
	parent, left, right *Element
	key                 int
}

// NewBinarySearchTree is constructor for BinarySearchTree
func NewBinarySearchTree() *BinarySearchTree {
	bstree := BinarySearchTree{
		root: nil,
	}
	return &bstree
}

// BinarySearchTree for int
type BinarySearchTree struct {
	root *Element
}

func (t *BinarySearchTree) inorderTreeWalk(p *Element) string {
	if p == nil {
		return ""
	}

	return t.inorderTreeWalk(p.left) +
		" " + strconv.Itoa(p.key) +
		t.inorderTreeWalk(p.right)
}

func (t *BinarySearchTree) preorderTreeWalk(p *Element) string {
	if p == nil {
		return ""
	}

	return " " + strconv.Itoa(p.key) +
		t.preorderTreeWalk(p.left) +
		t.preorderTreeWalk(p.right)
}

func (t *BinarySearchTree) insert(k int) {
	newElement := Element{
		left:  nil,
		right: nil,
		key:   k,
	}

	x := t.root
	var y *Element

	for x != nil {
		y = x
		if newElement.key < x.key {
			x = x.left
		} else {
			x = x.right
		}
	}
	newElement.parent = y
	if y == nil {
		t.root = &newElement
	} else if newElement.key < y.key {
		y.left = &newElement
	} else {
		y.right = &newElement
	}
}

func (t *BinarySearchTree) search(current *Element, k int) *Element {
	for current != nil && current.key != k {
		if k < current.key {
			current = current.left
		} else {
			current = current.right
		}
	}
	return current
}

func (t *BinarySearchTree) minimum(x *Element) *Element {
	for x.left != nil {
		x = x.left
	}
	return x
}

func (t *BinarySearchTree) maximum(x *Element) *Element {
	for x.right != nil {
		x = x.right
	}
	return x
}

func (t *BinarySearchTree) successor(x *Element) *Element {
	if x.right != nil {
		return t.minimum(x.right)
	}
	y := x.parent
	for y != nil && x == y.right {
		x = y
		y = y.parent
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)

	bstree := NewBinarySearchTree()

	nCommands := nextInt()
	for i := 0; i < nCommands; i++ {
		cmd := nextString()
		if cmd == "insert" {
			key := nextInt()
			bstree.insert(key)
		} else if cmd == "print" {
			fmt.Println(bstree.inorderTreeWalk(bstree.root))
			fmt.Println(bstree.preorderTreeWalk(bstree.root))
		} else if cmd == "find" {
			key := nextInt()
			r := bstree.search(bstree.root, key)
			if r != nil {
				fmt.Println("yes")
			} else {
				fmt.Println("no")
			}
		}
	}
}



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

int main(){
    long long n, a, b; cin >> n >> a >> b;

    if (a > b){
        cout << 0 << endl;
    } else if (a == b){
        cout << 1 << endl;
    } else if (n == 1 && a != b){
        cout << 0 << endl;
    } else {
        cout << ((n - 1) * b + a) - ((n - 1) * a + b) + 1 << endl;
    }
    return 0;
}

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

using namespace std;

#define PII pair<int, int>

const int N = 200010, INF = 0x3f3f3f3f;

typedef struct{
    int x, y, pos;
}state;

state a[N];
int cnt[N], p[N];
int n;
PII stk[N];
int tt = -1;

int cmp(const state &a, const state &b){
    return a.x < b.x;
}

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

int main(){
    cin >> n;
    
    for(int i = 0; i < n; i ++){
        int x, y;
        cin >> x >> y;
        
        a[i] = {x, y, i};
    }
    
    for(int i = 0; i < n; i ++) p[i] = i, cnt[i] = 1;
    
    sort(a, a + n, cmp);
    
    for(int i = 0; i < n; i ++){
        if(tt == -1) stk[++ tt] = {a[i].pos, a[i].y};
        else{
            int minv = a[i].y;
            while(~tt && a[i].y > stk[tt].second){
                minv = min(minv, stk[tt].second);
                int x = find(a[i].pos), y = find(stk[tt].first);
                if(x != y){
                    p[x] = y;
                    cnt[y] += cnt[x];
                }
                tt --;
            }
            stk[++ tt] = {a[i].pos, minv};
        }
    }
    
    for(int i = 0; i < n; i ++) cout << cnt[find(i)] << endl;
    
    return 0;
}

Measured memory_bytes: 8608
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using ll=long long int;

int main() {
    ll K, A, B;
    cin >> K >> A >> B;

    ll n = min(1+K, A);
    K -= n-1;
    if (B-A > 2) {
        n += (K/2) * (B-A);
        n += K%2;
    } else {
        n += K;
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
h,w = map(int,input().split())
s = [[] for j in range(h)]
for i in range(h):
    tmp = input()
    for j in tmp:
        if j == '.':
            s[i].append(1)
        else:
            s[i].append(0)


L = np.zeros((h,w))
R = np.zeros((h,w))
U = np.zeros((h,w))
D = np.zeros((h,w))
s = np.array(s)

for i in range(w):
    L[:,i] = (L[:,i-1]+1)*s[:,i]
    R[:,-1-i] = (R[:,-i]+1)*s[:,-1-i]
    
for i in range(h):
    U[i,:] = (U[i-1,:]+1)*s[i,:]
    D[-1-i,:] = (D[-i,:]+1)*s[-i-1,:]
    
print(int(np.max(L+R+D+U-3)))

Measured memory_bytes: 231472
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

long long pow_mod(long long x, int i, long long mod) {
  if (i == 0) return 1;
  ll tmp = pow_mod(x, i / 2, mod);
  if (i % 2 == 0) return (tmp * tmp) % mod;
  return (((tmp * tmp) % mod) * x) % mod;
}

int
main(int argc, char *argv[])
{
  long long n, k;
  scanf("%lld %lld", &n, &k);
  ll s = n - k + 1;
  for (int i = 1; i <= k; i++) {
    printf("%lld\n", s);
    s = ((n - k - i + 1) * (k - i) * s) % MOD;
    s *= pow_mod(i * (i + 1), MOD - 2, MOD);
    s %= MOD;
  }
  return 0;
}
		  


Measured memory_bytes: 128
main :: IO ()
main = do
  [sx, sy, tx, ty] <- map read . words <$> getLine
  let (w, h) = (tx - sx, ty - sy)
      s = concat [
            concat (replicate h "U"),
            concat (replicate w "R"),
            concat (replicate h "D"),
            concat (replicate (w+1) "L"),
            concat (replicate (h+1) "U"),
            concat (replicate (w+1) "R"),
            "D",
            "R",
            concat (replicate (h+1) "D"),
            concat (replicate (w+1) "L"),
            "U"
          ]
  putStrLn s

Measured memory_bytes: 1020
#!/usr/bin/python3
# import bisect
# from collections import Counter, deque, OrderedDict, defaultdict
# from copy import copy, deepcopy # pythonのみ．copyは1次元，deepcopyは多次元．
# from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    A=list(map(int,input().split()))

    from functools import reduce
    from math import gcd
    
    def lcm(A, B):
        return A * B // gcd(A, B)
    
    
    # リストを引数にとる
    val=reduce(lcm, A)
    ans=0
    MOD=10**9+7
    for i in A:
        ans+=val*pow(i,MOD-2,MOD)%MOD
        ans%=MOD
    print(ans)

    


    
resolve()

Measured memory_bytes: 74452
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BEcho solver = new BEcho();
        solver.solve(1, in, out);
        out.close();
    }

    static class BEcho {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] s = in.next().toCharArray();

            int[] z = ZAlgorithm.zAlgorithm(s);
            boolean answer = n % 2 == 0 && z[n / 2] == n / 2;
            out.println(answer ? "Yes" : "No");
        }

    }

    static class ZAlgorithm {
        private ZAlgorithm() {
        }

        public static int[] zAlgorithm(char[] s) {
            int n = s.length;
            int[] z = new int[n];
            z[0] = n;

            for (int i = 1, l = -1, r = -1; i < n; i++) {
                z[i] = r > i ? Math.min(r - i, z[i - l]) : 0;
                while (i + z[i] < n && s[i + z[i]] == s[z[i]])
                    z[i]++;
                if (i + z[i] > r) {
                    l = i;
                    r = i + z[i];
                }
            }
            return z;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    ll p[n+1];rep(i,1,n)cin>>p[i];
    ll a[n+1],b[n+1];
    rep(i,1,n){
        a[i]=(i-1)*n+1;
        b[n+1-i]=(i-1)*n+1;
    }
    rep(i,1,n){
        a[p[i]]+=i;
    }
    cout<<a[1];
    rep(i,2,n){
        cout<<' '<<a[i];
    }
    cout<<endl;
    cout<<b[1];
    rep(i,2,n){
        cout<<' '<<b[i];
    }
    cout<<endl;
    
    
    return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7


LONG D;
vector<LONG> cost(26);
//vector<vector<ULONG>> sati(D + 1, vector<ULONG>(27));
vector<vector<LONG>> sati;
vector<LONG> answer;
vector<int> lastDate(26, -1);
LONG satVal = 0;


LONG calcSabunScore(int eventType, LONG date) {

	LONG sabun = sati[date][eventType];
	// costsum
	LONG costSum = 0;
	for (int i = 0; i < 26; i++) {
		if (i != eventType) {
			costSum += cost[i] * (date - lastDate[i]);
		}
	}

	sabun -= costSum;
	

	return sabun;

}


int main(void) {
	// for A

	cin >> D;

	vector<LONG> tmpans(D);
	answer = tmpans;


	for (int i = 0; i < 26; i++) {
		cin >> cost[i];
	}



	for (int d = 0; d < D; d++) {
		vector<LONG> tmpsati(26);
		for (int i = 0; i < 26; i++) {
			cin >> tmpsati[i];
		}
		sati.push_back(tmpsati);
	}
	// finish data input


	// answerを決める
	for (int d = 0; d < D; d++) {
		int maxI = 0;
		LONG maxsabun = -1000000;
		for (int i = 0; i < 26; i++) {
			LONG sabun = calcSabunScore(i, d);
			if (sabun > maxsabun) {
				maxsabun = sabun;
				maxI = i;
			}
		}
		answer[d] = maxI;
		lastDate[maxI] = d;

	}

	/*
	// calc score
	for (int d = 0; d < D; d++) {
		LONG sabun = calcSabunScore(answer[d], d);

		satVal += sabun;

		lastDate[answer[d]] = d;

	}
	*/


	// output
	for (int d = 0; d < D; d++) {
		cout << answer[d] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5e3+5;
char s[maxn];
ll dp[maxn][3];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin>>n;
    cin>>(s+1);
    if(n<=3)
    {
        cout<<0<<'\n';
        return 0;
    }
    ll tol=(ll)n*(n-1)*(n-2)/6;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        dp[i][j]=dp[i-1][j];
        if(s[i]=='R')
            dp[i][0]++;
        else if(s[i]=='G')
            dp[i][1]++;
        else
            dp[i][2]++;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(s[i]==s[j])
                sum+=n-j;
            else
            {
                 if(j+j-i<=n)
                    sum++;
                char x='R'+'G'+'B'-s[i]-s[j];
                if(x=='R')
                {
                    sum+=dp[n][1]-dp[j][1]+dp[n][2]-dp[j][2];
                    if(j+j-i<=n&&s[j+j-i]!='R')
                    {
                        sum--;
                    }
                }
                else if(x=='G')
                {
                    sum+=dp[n][2]-dp[j][2]+dp[n][0]-dp[j][0];
                    if(j+j-i<=n&&s[j+j-i]!='G')
                    {
                        sum--;
                    }
                }
                else
                {
                    sum+=dp[n][1]-dp[j][1]+dp[n][0]-dp[j][0];
                    if(j+j-i<=n&&s[j+j-i]!='B')
                    {
                        sum--;
                    }
                }
            }
        }

    }

    cout<<tol-sum<<'\n';


}


Measured memory_bytes: 3632