akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 500000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int fact[MAX + 5];

int mul(int a, int b) {
    ll c = 1LL * a * b;
    if (c >= MOD) {
        c %= MOD;
    }
    return c;
}

int add(int a, int b) {
    int c = a + b;
    if (c >= MOD) {
        c -= MOD;
    }
    return c;
}

int sub(int a, int b) {
    int c = a - b;
    if (c < 0) {
        c += MOD;
    }
    return c;
}

int fastExp(int a, int b) {
    int c = 1;
    while (b) {
        if (b & 1) {
            c = mul(a, c);
        }
        b >>= 1;
        a = mul(a, a);
    }
    return c;
}

int inv(int a) {
    return fastExp(a, MOD - 2);
}

int ncr(int n, int r) {
    return mul(fact[n], mul(inv(fact[r]), inv(fact[n - r])));
}

int npr(int n, int r) {
    return mul(ncr(n, r), fact[r]);
}

void pre(int n) {
    int i;
    fact[0] = 1;
    for (i = 1; i <= n; ++i) {
        fact[i] = mul(fact[i - 1], i);
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n, m, ans, i, temp;
    cin >> n >> m;
    pre(m);
    ans = npr(m, n);
    ans = mul(ans, ans);
    for (i = 1; i <= n; ++i) {
        temp = npr(m - i, n - i);
        temp = mul(temp, temp);
        temp = mul(temp, npr(n, i));
        temp = mul(temp, ncr(m, i));
        if (i & 1) {
            ans = sub(ans, temp);
        } else {
            ans = add(ans, temp);
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 5096
n,m = map(int, input().split())
a = list()
for s in range(n):
    a.append(list(map(int, input().split())))
    
b = list()
for g in range(m):
    b.append(int(input()))

for ss in range(n):
    sum = 0
    for gg in range(m):
        sum += a[ss][gg] * b[gg]
    print(sum)


Measured memory_bytes: 6008
import java.util.*;
public class Main {
    public static void main (String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        if (a < b&&b < c) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26132
import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int count = scanner.nextInt();
        int sum = scanner.nextInt();
        int ten_thou = 10000;
        int five_thou = 5000;
        int thou = 1000;
        int z = 0;
        boolean lie = true;
        
        
        
        for(int x=0;x<count+1;x++){
            if(sum % ten_thou == 0 && sum/ten_thou==count){
                System.out.print(count+" 0 0");
                lie = false;
                break;
            }else{
            for(int y=0;y<count+1-x;y++){
                z = count - (x+y);
                        if((10000*x + 5000*y + 1000*z) == sum){
                            
                           System.out.print(x+" "+y+" "+z);
                           lie = false;
                            break;
                        }
            }
                }
                
                if(!lie)break;
                
            }
            
            if(lie){
                    
                    System.out.print("-1 -1 -1");
                }
            
        }
        
        
}

Measured memory_bytes: 39552
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int sgn(int t) {
    return t <= 0 ? 0 : 1;
}

struct P {
    bool operator<(const P &p) const {
        int t0 = sgn(d);
        int t1 = sgn(p.d);
        if (t0 != t1) return t0 > t1;
        if (t0 == 1) {
            return m > p.m;
        } else {
            return d - m > p.d - p.m;
        }
    }
    int d, m;
};

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

    int n;
    cin >> n;

    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    vector<P> p(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int d = 0, m = 0;
        int l = s[i].size();
        for (int j = 0; j < l; j++) {
            d += s[i][j] = s[i][j] == '(' ? 1 : -1;
            m = min(m, d);
        }
        p[i] = { d, m };
        sum += d;
    }

    if (sum != 0) {
        cout << "No" << endl;
        exit(0);
    }

    sort(p.begin(), p.end());

    int b = 1;
    sum = 0;
    for (int i = 0; i < n; i++) {
        auto [d, m] = p[i];
        if (sum + m < 0) {
            b = 0;
            break;
        }
        sum += d;
    }
    cout << (b ? "Yes" : "No") << endl;

    // mが負のときはそれだけの貯金があるときしか使えない
    // 貯金の稼ぎ方はdが正のやつ dが正でもmは負かも dが負ならmも負
    // まずmが0でdが正のやつを使う これは確定 後回しにする意味もなさそう
    // 次にmが負のしかなくなったらdが正のやつでmの絶対値が小さいものから使う
    // dが0か負のしかなくなったらmの絶対値が大きいものから使う とも限らんな
    // d-mが大きいものから使う 最後にd-mだけ上がるわけでそれだけの余裕がある

    return 0;
}

Measured memory_bytes: 42688
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int flag = 0;
  rep(i,n){
    if (s[i]==s[i+1]){
      flag = 1;
      break;
    }
  }
  if (flag ==0){
    cout<<"Good"<<endl;
  }else{
    cout<<"Bad"<<endl;
  }
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N, M;
int A[MAX_N];

signed main()
{
  cin >> N >> M;
  int NN = 1;
  bool flag = true;

  int cnt0 = 0, cnt1 = 0;

  REP(n,N) {
    cin >> A[n];
    A[n] /= 2;
    if(A[n] % 2 == 0) {
      cnt0++;
    } else {
      cnt1++;
    }
    NN = lcm(NN, A[n]);
    if(NN > M) {
      flag = false;
    }
  }

  if(!flag) {
    cout << 0 << endl;
    return 0;
  }

  if(cnt0 > 0 && cnt1 > 0) {
    cout << 0 << endl;
    return 0;
  }

  while(cnt0 == N) {
    cnt0 = 0; cnt1 = 0;
    REP(n,N) {
      A[n] /= 2;
      if(A[n] % 2 == 0) {
        cnt0++;
      } else {
        cnt1++;
      }
    }
    if(cnt0 > 0 && cnt1 > 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << (M/NN+1)/2 << endl;

  return 0;
}


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

int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double co, com = 0, s=1, w=1;
    int msw, ms=0;


    //s+w<f&&s<=w*e/100 min w/s
    //s=(c,d),w(100a,100b)
    //まずみずの選び方の全列挙したい
    rep(i,f/(a*100)+1){
        //a=0~ 30
        rep(j,f/(b*100)+1){
            //b=0~ 30
            w = (a*i + b*j) * 100;
            if(w==0)
                continue;
            rep(k,w*e/(100*c)+1){
                //c=0~ 60
                rep(l,w*e/(100*d)+1){
                    //d=0~ 60
                    s = c * k + d * l;
                    if(w+s>f){
                        //総重量f以下
                        continue;
                    }
                    if(s>w*e/100){
                        //砂糖の溶け残り無し
                        continue;
                    }
                        co = 100 * s / (w + s);
                    if(co>com){
                        com = co;
                        ms = s;
                        msw = w + s;
                    }
                }
            }
        }
    }
    if(ms==0){
        cout << a * 100 << " " << 0 << endl;
    }else{
        cout << msw << " " << ms << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______ 
 * |\  \|\  \  |\  ___ \  |\  ___ \
 * \ \  \/  /|_\ \   __/| \ \   __/|
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxP = 4010;
const int mxN = 2010;
const int inf = 10000010;
int BIT[mxP];
void upd(int ind, int val) {
	while (ind < mxP) {
		BIT[ind] += val;
		ind |= ind + 1;
	}
}

int get(int ind) {
	int res = 0;
	while (ind >= 0) {
		res += BIT[ind];
		ind = (ind & (ind + 1)) - 1;
	}
	return res;
}

int W[mxN],B[mxN];
int dp[mxN][mxN];
int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N,x;
	string s;
	cin >> N;
	for(int i = 0;i < (N<<1);i++) {
		cin>>s>>x;
		x--;
		if(s[0] == 'W') {
			W[x] = i;
		} else {
			B[x] = i;
		}
	}
	dp[N][N] = 0;
	for(int i = N;i >= 0;i--) {
		if(i < N) upd(B[i],1);
		for(int j = N - (i == N);j >= 0;j--) {
			dp[i][j] = inf;
			if(j < N) {
				upd(W[j],1);
				dp[i][j] = min(dp[i][j],dp[i][j+1] + get(W[j]-1));
			}
			if(i < N) {
				dp[i][j] = min(dp[i][j],dp[i+1][j] + get(B[i]-1));
			}
//			cerr<<dp[i][j]<<" \n"[j == 0];
		}
		for(int j = 0;j < N;j++) upd(W[j],-1);
	}
	cout<<dp[0][0]<<'\n';
	return 0;
}



Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n, m; cin >> n >> m;
    vector<ll> a(n), s(n+1,0); rep(i,n) cin >> a[i];
    rep(i,n) s[i+1] = (s[i] + a[i])%m;
    ll ans = 0;


    map<ll,ll> mp;

    rep(i,n+1){
        ans += mp[s[i]];
        mp[s[i]]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b);
int main()
{
    int N;
    int ans;
    cin >> N;
    vector<int> A;
    for(int i=0; i<N; i++)
    {
    	int a;
    	cin >> a;
    	A.push_back(a);
    }
    ans = gcd(A[0], A[1]);
    for(int i=2; i<N; i++)
    {
       ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
	return 0;
}

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



Measured memory_bytes: 892
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 998244353

const int N = 200005;
LL a[N], s[N];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%lld", a + i);
		s[i + 1] = a[i] + s[i];
	}
	int d1 = 1, c = 2, d2 = 3;
	LL ret = 1e18;
	for (; c < n - 1; c++) {
		while (abs((s[c] - s[d1]) - abs(s[d1] - s[0])) > abs((s[c] - s[d1 + 1]) - abs(s[d1 + 1] - s[0])))d1++;
		while (abs((s[n] - s[d2]) - abs(s[d2] - s[c])) > abs((s[n] - s[d2 + 1]) - abs(s[d2 + 1] - s[c])))d2++;
		if (d1 == c)d1--;
		if (d2 == c)d2++;
		if (d2 == n)d2--;
		LL smin = 1e18, smax = -1;
		ret = min(ret, max(s[d1], max(s[c] - s[d1], max(s[d2] - s[c], s[n] - s[d2]))) - min(s[d1], min(s[c] - s[d1], min(s[d2] - s[c], s[n] - s[d2]))));
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3328
n,m=map(int,input().split())

a=[]
b=[]
for i in range(n):
	a.append(input())
for i in range(m):
	b.append(input())

ans="No"
for i in range(n-m+1):
	for j in range(n-m+1):
		check=0
		for k in range(m):
			for l in range(m):
				if b[k][l]==a[i+k][j+l]:
					check+=1
					if check==m*m:
						ans="Yes"
				else:
					break
			else:
				continue
			break
print(ans)	

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string n;
    cin >> n;

    if(n[0] == '7' || n[1] == '7' || n[2] == '7'){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int l, r, d;
	cin >> l >> r >> d;
	int ans = (r / d) - (l / d);
	if (l % d == 0)
		ans++;
	cout << ans << endl;
	return 0;
}

//!

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#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 repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const int MAX = 2000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main()
{
	int x, y;
	int a, b;
	bool flag = false;
	a = b = 0;

	cin >> x >> y;

	if ((x + y) % 3 != 0)
	{
		cout << 0 << endl;
		return 0;
	}

	b = (2 * x - y) / 3;
	a = x - 2 * b;

	COMinit();
	cout << COM(a + b, a) << endl;

	return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[213456], aa[213456];

signed main() {
	int n, a = 0, ans = 1; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	sort(test, test + n);
	for (int h = 0; h < n; h++) { a += test[h]; aa[h] = a; }
	for (int h = n - 2; h >= 0; h--) {
		if (test[h] * 2 >= test[h + 1]) {
			ans++;
		}
		else if (aa[h] * 2 >= test[h + 1]) { 
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

ll llabs(ll a, ll b){
  if(a>=b) return a-b;
  else return b-a;
}

ll llmax(ll a, ll b){
  if(a>=b) return a;
  else return b;
}

ll llmin(ll a, ll b){
  if(a<=b) return a;
  else return b;
}


// 降順P番目までは確実に採用される
// 絶対に問題セットに採用されない問題：ジャッジ全員が点数を入れても降順P番目に点数が入らない場合
// そのとき、他の問題への投票は、降順P番目未満の問題
// V問を選ぶ：昇順V-1問目までの場合は、他の問題に投票する場合を考えなくてはいけない　→　不要？？？？
// 初期で降順P番目の問題の点数と比較する必要がありそう

// ジャッジにより最大+m点が加算される
// 降順P番目の問題に加点されてしまうのは、V>Pのとき

// 入れたい問題には、全員が点をいれればいい
// i番目の問題を入れるとする
// それ以外の点数の振り方は、降順でP-1番目までの問題＞入れたい問題よりも昇順で早い問題
// 困るとき：(p-1)+i < v のとき(予定よりも多くの問題に点を入れなければいけないとき)

signed main(){
  VVI c;
  VI t(3);
  rep(i,3){
    VI d(3); rep(j,3) cin>>d[j]; c.PB(d);
    t[i] = 0;
  }
  rep(i,3){
    rep(j,3){
      t[(i+j)%3] += c[i][j];
    }
  }
  cerr << t[0] SP t[1] SP t[2] << endl;
  if(t[0]==t[1]&&t[1]==t[2]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
H, W = map( int, input().split() )

h_set = set()
w_set = set()
B = [input() for i in range(H)]
for i in range(H):
  for j in range(W):
    if B[i][j] == '#':
      w_set.add(j)
      h_set.add(i)
      
for i in range(H):
  if i in h_set:
    t = ""
    for j in range(W):
      if j in w_set:
        t += B[i][j]
    print(t)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
char col[N];
int x,y,f[N],ans,sum,n,vis[N];
set<int>g[N];
queue<int>q;
int dfs(int x,int fa=-1){
	int mx=0;
	for (int i:g[x])
		if (i!=fa){
			int u=dfs(i,x);
			ans=max(ans,f[x]+u+mx);
			mx=max(mx,u);
		}
	return mx+f[x];
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		g[x].insert(y);
		g[y].insert(x);
	}
	scanf("%s",col+1);
	for (int i=1;i<=n;i++)
		if (col[i]=='B'&&(int)g[i].size()<=1)q.push(i),vis[i]=1;
	while (!q.empty()){
		int x=q.front();q.pop();
		for (int i:g[x]){
			g[i].erase(x);
			if ((int)g[i].size()<=1&&col[i]=='B'&&!vis[i])q.push(i),vis[i]=1;
		}
		g[x].clear();
	}
	int rt=0;
	for (int i=1;i<=n;i++){
		sum+=g[i].size();
		if ((col[i]=='W')^(g[i].size()&1))sum++,f[i]=2;
		else f[i]=0;
		if (col[i]=='W')rt=i;
	}
	if (rt)dfs(rt);
	printf("%d\n",sum-ans);
	return 0;
}


Measured memory_bytes: 20992
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;

struct TimeStamp {
	int h, m, s;
	bool operator<(const TimeStamp &ts) const {
		if(h < ts.h){ return true; }
		if(h > ts.h){ return false; }
		if(m < ts.m){ return true; }
		if(m > ts.m){ return false; }
		return s < ts.s;
	}
};

typedef pair<TimeStamp, TimeStamp> ptt;
typedef pair<TimeStamp, int> pti;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<ptt> t(n);
		priority_queue< pti, vector<pti>, greater<pti> > pq;
		for(int i = 0; i < n; ++i){
			cin >> t[i].first.h; cin.ignore();
			cin >> t[i].first.m; cin.ignore();
			cin >> t[i].first.s;
			cin >> t[i].second.h; cin.ignore();
			cin >> t[i].second.m; cin.ignore();
			cin >> t[i].second.s;
			pq.push(pti(t[i].first, i));
		}
		int pool = 0, answer = 0;
		while(!pq.empty()){
			pti p = pq.top();
			pq.pop();
			if(p.second < 0){
				++pool;
			}else{
				pq.push(pti(t[p.second].second, -1));
				if(pool == 0){
					++answer;
				}else{
					--pool;
				}
			}
		}
		cout << answer << endl;
	}
	return 0;
}

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

string S; int N, cnt = 0, minx = 0;

int main() {
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) { if (S[i] == '.') cnt++; }
	minx = cnt;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '#') cnt++;
		else cnt--;
		minx = min(minx, cnt);
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(a) (int)a.size()
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

typedef db T;
const db eps = 1e-9 , pi = acosl(-1.);
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
  T x,y; P(){} P(T x,T y):x(x),y(y){}
  P operator - (const P&b) const {return P(x-b.x,y-b.y);}
  P operator + (const P&b) const {return P(x+b.x,y+b.y);}
  T operator * (const P&b) const {return x*b.x+y*b.y;}
  T operator / (const P&b) const {return x*b.y-y*b.x;}
  P operator * (const T&k) const {return P(x*k,y*k);}
  P operator / (const T&k) const {return P(x/k,y/k);}
};
T norm(P a){return a*a;}
T abs(P a) {return sqrtl(norm(a));}
P proj(P p,P a,P b){return (b-a)*((p-a)*(b-a)/norm(b-a))+a;}
P reflect(P p,P a,P b){return proj(p,a,b)*2-p;}
T cross(P o,P a,P b){return (a-o)/(b-o);}
int crossOp(P o,P a,P b){return sgn(cross(o,a,b));}
bool onPS(P p,P s,P t){return sgn((t-s)/(p-s))==0&&sgn((p-s)*(p-t))<=0;}
struct L{ P s,t;L(){} L(P s,P t):s(s),t(t){}};
P insLL(L a,L b){ // line x line
  P s = a.s - b.s , v = a.t - a.s , w = b.t - b.s;
  db k1 = s / w , k2 = w / v;
  if(sgn(k2) == 0) return abs(b.s - a.s) < abs(b.t - a.s) ? b.s : b.t;
  return a.s + v * (k1 / k2);
}
bool isSS(L a,L b){ // seg x seg , replace x->y to accelerate
  T c1=(a.t-a.s)/(b.s-a.s),c2=(a.t-a.s)/(b.t-a.s);
  T c3=(b.t-b.s)/(a.s-b.s),c4=(b.t-b.s)/(a.t-b.s);
  return sgn(c1) * sgn(c2) <= 0 && sgn(c3) * sgn(c4) <= 0 &&
    sgn(max(a.s.x,a.t.x) - min(b.s.x,b.t.x)) >= 0 &&
    sgn(max(b.s.x,b.t.x) - min(a.s.x,a.t.x)) >= 0 &&
    sgn(max(a.s.y,a.t.y) - min(b.s.y,b.t.y)) >= 0 &&
    sgn(max(b.s.y,b.t.y) - min(a.s.y,a.t.y)) >= 0;
}
db disPL(P p,L a){return fabs((a.t-a.s)/(p-a.s)) / abs(a.t-a.s);}
db disPS(P p,L a){ // p x seg dis
  if(sgn((a.t-a.s)*(p-a.s)) == -1) return abs(p-a.s);
  if(sgn((a.s-a.t)*(p-a.t)) == -1) return abs(p-a.t);
  return disPL(p,a);
}
db disSS(L a,L b){ // seg x seg dis
  if(isSS(a,b)) return 0;
  return min(min(disPS(a.s,b),disPS(a.t,b)),min(disPS(b.s,a),disPS(b.t,a)));
}
typedef vector<P> polygon;
T area(polygon A) { // multiple 2 with integer type
  T res=0;
  rep(i,0,sz(A)) res+=A[i]/(A[(i+1)%sz(A)]);
  return fabs(res) / 2;
}
bool isconvex(polygon A){ // counter-clockwise
  bool ok=1;int n=sz(A);
  rep(i,0,2) A.pb(A[i]);
  rep(i,0,n) ok&=((A[i+1]-A[i])/(A[i+2]-A[i]))>=0;
  return ok;
}

P a, b, c, d;
polygon poly;

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	int q;
	cin >> q;
	cout << setiosflags(ios::fixed);
	cout << setprecision(1);
	while(q--) {
		cin >> a.x >> a.y;
		poly.pb(a);
	}
	cout << isconvex(poly) << endl;
	return 0;
}


Measured memory_bytes: 3328
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        if i+j>n:continue
        elif 10000*i+5000*j+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            break
    else:continue
    break
else:print(-1,-1,-1)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
ll mod = 1000000007;
int INF = 0x3f3f3f3f;

vector<vector<int> > G;
vector<int> a;
vector<int> a2;
vector<int> res;
vector<bool> used;

class ST {
public:
    vector<int> t;
    int n;

    int combine(int l, int r) {
        return max(l, r);
    }

    ST(int n) {
        this->n = n;
        t = vector<int>(n << 1, 0);
    }


    void update(int i, int value) {
        t[i += n] = value;
        i >>= 1;
        while (i > 0) {
            t[i] = combine(t[i << 1], t[i << 1 | 1]);
            i >>= 1;
        }
    }

    //[l, r)
    int query(int l, int r) {
        int resl = 0, resr = 0;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if ((l & 1) != 0) resl = combine(resl, t[l++]);
            if ((r & 1) != 0) resr = combine(t[--r], resr);
        }
        return combine(resl, resr);
    }
};
map<int, int> mp;
void dfs(ST& st, int id, int maxm) {
    int t1 = st.query(0, mp[a[id]]);
    maxm = max(maxm, t1 + 1);
    res[id] = maxm;
    used[id] = true;
    int t2 = st.query(mp[a[id]], mp[a[id]] + 1);
    st.update(mp[a[id]], t1 + 1);

    for(auto v : G[id]) {
        if(!used[v]) {
            dfs(st, v, maxm);
        }
    }

    st.update(mp[a[id]], t2);
}

int main() {
    int n;
    cin >> n;
    a = vector<int>(n + 1);
    res = vector<int>(n + 1);
    a2 = vector<int>(n + 1);
    used = vector<bool>(n + 1 , false);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    G = vector<vector<int> >(n + 1, vector<int>());
    for(int i = 1; i <= n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }


    for(int i = 1; i <= n; ++i) {
        if(mp.find(a[i]) == mp.end()) {
            mp[a[i]] = 0;
        }
    }
    int id = 0;
    for(auto& v : mp) {
        v.second = id++;
    }

    ST st(mp.size());

    dfs(st, 1, 0);

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

    return 0;
}



Measured memory_bytes: 42776
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <functional>
#include <stack>
using namespace std;

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

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


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int N;cin>>N;
  if(N%2==0){
    cout<<N/2<<endl;
  }
  else{
    cout<<N/2+1<<endl;
  }
}

Measured memory_bytes: 888
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

long long int f(long long int a) {
    long long int res[] = {a, 1, a+1, 0};
    return res[a % 4];
}

long long int getXor(long long int a, long long int b) {
    return f(b) ^ f(a);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    long long int a,b;
    cin>>a>>b;
    cout<<getXor(max(a-1,(long long int)0),b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ld r;
	cin >> r;
	cout << fixed << setprecision(10) << 2.0 * acos(-1) * r;

	return 0;
}


Measured memory_bytes: 3816
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=3000+5;
int n,m,k;
ll ga[N][N];
ll dp[N][N][4];
ll bmax(ll *b)
{
	ll ans=0;
	for(int i=0;i<=3;i++)
		ans=max(ans,b[i]);
	return ans;
}
int main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int i,j,r;
	cin>>n>>m>>k;
	for(i=1;i<=k;i++)
	{
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		ga[x][y]=z;
	}
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			for(r=0;r<=3;r++)
			{
				if(ga[i][j]==0)
				{
					if(r==0)
						dp[i][j][r]=max(bmax(dp[i-1][j]),dp[i][j-1][0]);
					else
					{
						dp[i][j][r]=dp[i][j-1][r];					
					}
				}
				else
				{
					if(r==0)
						dp[i][j][r]=max(bmax(dp[i-1][j]),dp[i][j-1][0]);
					else if(r==1)//max(max(bmax(dp[i-1][j])+ga[i][j],dp[i][j-1][r]),dp[i][j-1][r-1]+ga[i][j]);
						dp[i][j][r]=max(max(bmax(dp[i-1][j])+ga[i][j],dp[i][j-1][r]),dp[i][j-1][r-1]+ga[i][j]);					
					else 
						dp[i][j][r]=max(dp[i][j-1][r],dp[i][j-1][r-1]+ga[i][j]);
					

					
				}
			}
		}
	}

	cout<<bmax(dp[n][m])<<endl;
}


Measured memory_bytes: 355736
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



/*
 O(QlogN+N)
 追加する直線の傾きが狭義単調減少であること
 maxを求めるときは値と傾きに-1をかけること
 */
template<typename T>
class Comvex_Hull_Trick{
private:
    typedef pair<T,T> line; //y切片,傾き
    deque<line> D;
    
    inline T point(const line &L,const T &x) const {return L.F+L.S*x;}
    
    inline bool is_need(const line &A,const line &B,const line &C) const {
        return (C.F-A.F)*(A.S-B.S)>(B.F-A.F)*(A.S-C.S);
    }
    
public:
    Comvex_Hull_Trick(){}
    
    void add_line(const line &L){
        while(!D.empty() && D.back().F>=L.F){D.pop_back();}
        while(D.size()>=2 && !is_need(D[D.size()-2],D.back(),L)){D.pop_back();}
        D.push_back(L);
    }
    
    T search(const T &x) const {
        ll l=0;
        ll r=D.size()-1;
        while(l+1<r){
            ll m=l+(r-l)/2;
            if(point(D[m],x)<point(D[m+1],x)){r=m;}
            else{l=m+1;}
        }
        for(ll i=l;i<r;i++){
            if(point(D[i],x)<point(D[i+1],x)){return point(D[i],x);}
        }
        return point(D[r],x);
    }
    
    pair<T,T> search_line(const T &x) const {
        ll l=0;
        ll r=D.size()-1;
        while(l+1<r){
            ll m=l+(r-l)/2;
            if(point(D[m],x)<point(D[m+1],x)){r=m;}
            else{l=m+1;}
        }
        for(ll i=l;i<r;i++){
            if(point(D[i],x)<point(D[i+1],x)){return D[i];}
        }
        return D[r];
    }
    
    pair<T,T> back() const {return D.back();}
    
    unsigned long size() const {return D.size();}
    
    bool empty() const {return D.empty();}
};



int main(){
    ll n,c;
    cin>>n>>c;
    vector<ll> h(n);
    for(auto &i:h){cin>>i;}
    Comvex_Hull_Trick<ll> C;
    C.add_line({h[0]*h[0]+c,-2*h[0]});
    for(int i=1;i+1<n;i++){
        ll w=C.search(h[i]);
        w+=h[i]*h[i]*2+c;
        C.add_line({w,-2*h[i]});
    }
    cout<<C.search(h.back())+h.back()*h.back()<<endl;
    
    
    
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string> str(N);
  for(int i=0;i<N;i++){
    cin >> str[i];
  }
  int tailB=0;
  int headA=0;
  int hAtB=0;
  int ab = 0;
  for(int i=0;i<N;i++){
    if(str[i][0]=='B'&&str[i][str[i].length()-1]=='A'){
      hAtB++;
    }else if(str[i][0]=='B'){
      headA++;
    }else if(str[i][str[i].length()-1]=='A'){
      tailB++;
    }
    for(int j=0;j<str[i].length()-1;j++){
      if(str[i][j]=='A'&&str[i][j+1]=='B'){
        ab++;
      }
    }
  }
  int hA=0;
  int tB=0;
  if(hAtB>0){
    if(headA>0){
      hA = 1;
    }
    if(tailB>0){
      tB=1;
    }
  }
  int ans  = ab + max(hAtB-1,0) + hA+tB + min(headA-hA,tailB-tB);
  cout << ans <<'\n';
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

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

int main(){
    ll n;cin>>n;
    string s;cin>>s;
    if(n % 2 == 1){
        cout << "No" << ednl;
        return 0;
    }
    rep(i,0,n/2){
        if(s[i] != s[i+n/2]){
            cout << "No" << ednl;
            return 0;
        }
    }
    cout << "Yes" << ednl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int h, w; cin >> h >> w;
  vector<vector<bool>> v(h, vector<bool>(w, false));
  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      char tmp; cin >> tmp;
      if(tmp == '#') v[i][j] = true;
    }
  }

  vvi ans(h, vi(w, 0));
  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      for(int k=-1;k<=1;++k) {
        for(int l=-1;l<=1;++l) {
          if(!(0 <= i+k && i+k < h && 0 <= j+l && j+l < w)) continue;
          ans[i][j] += v[i+k][j+l];
        }
      }
    }
  }

  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      if(v[i][j]) cout << "#";
      else cout << ans[i][j];
    }
    cout << endl;
  }

}


Measured memory_bytes: 256
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
s=acinput()

s.insert(0,0)
dp=[0]*(N+1)
#dp[0]=int(1==s[0])

for i in range(1,N+1):
    if s[i]==i:
        dp[i]=dp[i-1]+1
        try:
            s[i+1]=s[i]
        except:
            pass
    else:
        dp[i]=dp[i-1]
print(dp[-1])

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

using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
int inf_int=1e8;
ll inf_ll=4e18;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define siz(a) a.size()
#define sz size()



#define FILE "kebab"

const int MAXN = 1e5+100;
int a[MAXN];

template<typename T>
void print(vector<T>& a){
    for(int i=0;i<a.size();++i){
        if(i>0)
            cout <<" ";
        cout <<a[i];
    }
    cout <<"\n";
}

int cost[MAXN];
void solve(){
    cin >> cost[1] >> cost[2] >> cost[4] >> cost[8];
    ll n;
    cin >> n;
    n = n * 4;
    cost[2] = min(cost[2],2*cost[1]);
    cost[4] = min(cost[4],2*cost[2]);
    cost[8] = min(cost[8],2*cost[4]);

    ll ans = 0;
    ans += n/8 * cost[8]; n%=8;
    ans += n/4 * cost[4]; n%=4;
    ans += n/2 * cost[2]; n%=2;
    ans += n * cost[1];
    cout << ans<<"\n";

}
int main()
{
    #ifdef zxc
        freopen("input.txt","r",stdin);
      //  freopen("output1.txt","w",stdout);
    #else
       // freopen(FILE".in","r",stdin);
     //  freopen(FILE".out","w",stdout);
    #endif // zxc

    solve();
}


Measured memory_bytes: 256
from collections import defaultdict
N,M = map(int,input().split())
dic = defaultdict(list)
for i in range(M):
    a,b = map(int,input().split())
    dic[a].append(b)
def solve(dic):
    for s in dic[1]:
        for m in dic[s]:
            if m == N:
                return True
if solve(dic): print('POSSIBLE')
else: print('IMPOSSIBLE')

Measured memory_bytes: 48144
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define UNWORDS(vec, str) for(int i = 0; i < (vec).size(); ++i) cout << (i ? str : "") << (vec)[i]
#define UNLINES(vec) for(int i = 0; i < (vec).size(); ++i) cout << (vec)[i] << endl
#define RS resize
#define CLR clear
#define PB push_back
using namespace std;


int main(){
	int MAP[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}};
	int cur;
	string root;
	
	while(cin >> root, root != "#"){
		cur = 0;
		
		for(int i = 0; i < root.length(); ++i){
			cur = MAP[cur][root[i] - '0'];
			
			if(cur == -1) break;
		}
		
		if(cur == 5) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1180
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	long A, B, K;
	long x, y;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		A = Long.parseLong(tokens[0]);
		B = Long.parseLong(tokens[1]);
		K = Long.parseLong(tokens[2]);
	}

	void calc() {
		x = A;
		y = B;
		x = A - K;
		if (x < 0) {
			y = B + x;
			x = 0;
			if (y < 0) {
				y = 0;
			}
		}
	}

	void showResult() {
		System.out.println(x + " " + y);
	}
}

Measured memory_bytes: 21204
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD = 1000000007;
/*
cin >> n;
vi a(n);
rep(i,n)cin>>a[i];
*/
int N,M;
vi gr[114514];
bool visited[114514];
int ma=0;
void dfs(int x,int le){
	ma=max(ma,le);
	for(int i=0;i<gr[x].size();i++){
		int pt=gr[x][i];
		dfs(pt,le+1);
	}
}
int main(){
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;a--;b--;
		gr[a].pb(b);
		gr[b].pb(a);
	}
	for(int i=0;i<N;i++)visited[i]=false;
	vi ans1,ans2;
	ans1.pb(1);
	visited[0]=true;
	int x=0;
	int now;
	while(1){
		for(int i=0;i<gr[x].size();i++){
			now=gr[x][i];
			if(visited[now]==false){
				visited[now]=true;
				ans1.pb(now+1);
				goto HOG;
				
			}
		}
		break;
	 HOG:
		x=now;
	}
	x=0;
	while(1){
		for(int i=0;i<gr[x].size();i++){
			now=gr[x][i];
			if(visited[now]==false){
				visited[now]=true;
				ans2.pb(now+1);
				goto HOGE;
				
			}
		}
		break;
	  HOGE:
		x=now;
	}
	cout<<ans1.size()+ans2.size()<<endl;
	for(int i=(ans1.size()-1);i>=0;i--)cout<<ans1[i]<<" ";
	for(int i=0;i<ans2.size();i++)cout<<ans2[i]<<" ";
	cout<<endl;
	
}


Measured memory_bytes: 7160
import sys
input=sys.stdin.readline

def BellmanFord(Edges,num_v,start,goal):
    inf=float('inf')
    Dist=[inf]*num_v
    Dist[start]=0
    for _ in range(num_v):
        for fr,to,cost in Edges:
            if Dist[fr]!=inf and Dist[to]>Dist[fr]+cost:
                Dist[to]=Dist[fr]+cost
    d=Dist[goal]
    for _ in range(num_v):
        for fr,to,cost in Edges:
            if Dist[fr]!=inf and Dist[to]>Dist[fr]+cost:
                Dist[to]=-inf
    if d!=Dist[goal]:
        return -inf
    return d

n,m,p=map(int,input().split())
Edges=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1; b-=1
    Edges.append((a,b,-(c-p)))
d=BellmanFord(Edges,n,0,n-1)
print(-1 if d==-float('inf') else max(0,-d))

Measured memory_bytes: 43484
H, W = map(int, input().split())
m = []
m.append('#'*(W+2))
white = 0
for i in range(H):
  s = input()
  m.append(list('#' + s + '#'))
  white += s.count('.')
m.append('#'*(W+2))
 
op = set([(1, 1)])
dist = 0
while len(op) > 0:
  dist += 1
  next_op = set()
  for y, x in op:
    m[y][x] = dist
    if (y, x) == (H, W):
      print(white - dist)
      exit()
 
    for dx,dy in [0,1],[0,-1],[1,0],[-1,0]:
      if m[y-dy][x-dx] == '.':
        next_op.add((y-dy,x-dx))
  op = next_op
 
print('-1')

Measured memory_bytes: 3064