akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
import copy

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    if _solve(N):
        return 'Yes'
    return 'No'


def _solve(n):
    if n == 0:
        return True
    elif n < 0:
        return False
    else:
        ret = []
        ret.append(_solve(n - 7))
        ret.append(_solve(n - 4))
        return any(ret)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3436
#include "bits/stdc++.h"
using namespace std;
int findSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) { // n が 0 になるまで
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    for (int i = 1; i <= N; ++i) {
        int sum = findSumOfDigits(i); // i の各桁の和
        if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
            total += i;
        }
    }
    cout << total << endl;
}

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

class Point {
public:
    double x, y;
    Point(double x, double y) : x(x), y(y) {};
};

class Line {
public:
    double m, n; // y = m * x + n
    Line(Point p1, Point p2) {
        m = (p2.y - p1.y) / (p2.x - p1.x);
        n = p1.y - m * p1.x;
    }
};

Point symmetricPoint(Point p1, Line L) {
    double x = ((1 - L.m * L.m) * p1.x + 2 * L.m * (p1.y - L.n)) / (L.m * L.m + 1);
    double y = L.m * (p1.x + x) + 2 * L.n - p1.y;
    return Point(x, y);
}

int main() {
    double x1,y1,x2,y2,xq,yq;
    char c;
    while (cin>>x1>>c>>y1>>c>>x2>>c>>y2>>c>>xq>>c>>yq) {
        double rx, ry;
        if (x1 == x2) {
            rx = 2 * x1 - xq;
            ry = yq;
        } else {
            Line l(Point(x1, y1), Point(x2, y2));
            Point p = symmetricPoint(Point(xq, yq), l);
            rx = p.x;
            ry = p.y;
        }
        cout.precision(6);
        cout << fixed << rx << " " << ry << endl;
    }
    return 0;
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(6);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    ll a, b, n;
    cin >> a >> b >> n;
    if (n >= b - 1) {
        cout << (a * b - a) / b;
    } else {
        cout << (a * n) / b;
    }
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 3616
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

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

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    string s1, s2;
    cin >> s1 >> s2;

    reverse(s1.begin(), s1.end());
    if (s1 == s2) cout << "YES";
    else cout << "NO";

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));  // 2次元配列初期化
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args){
        int[] num = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
        final int N, M; {int[] a = in.ii(); N = a[0]; M = a[1];}
        int[] A = in.ii();
        Arrays.sort(A);

        int[] dp = new int[N+1];
        dp[0] = 0;
        final int MIN = -Integer.MIN_VALUE;
        for(int i = 1; i < N+1; i++){
            int max = MIN;
            for(int j = 0; j < M; j++){
                int k = i-num[A[j]];
                if(k >= 0)
                    max = Math.max(max, dp[k] + 1);
            }
            dp[i] = max;
        }     

        int d = dp[N];
        int n = N;
        for(int i = 0; i < d; i++){
            for(int j = M-1; j >= 0; j--){
                int tmp = n-num[A[j]];
                if(tmp >= 0 && dp[tmp] == dp[n]-1){
                    out.print(A[j]);
                    n -= num[A[j]];
                    break;
                }
            }
        }
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

int main()
{
  int n,a;
  cin>>n>>a;
  std::vector<int> x(n+1);
  x[0]=0;
  for (int i = 1; i <= n; ++i)
  {
    cin>>x[i];
  }
  int64_t dp[60][60][2600];
  for (int i = 0; i <= n; ++i)
  {
    for (int k = 0; k <= n; ++k)
    {
      for (int j = 0; j <= 2500; ++j)
      {
        if(i==0&&k==0&&j==0) dp[i][k][j]=1;
        else if(j<x[i]&&i>=1) dp[i][k][j]=dp[i-1][k][j];
        else if(j>=x[i]&&i>=1) dp[i][k][j]=dp[i-1][k][j]+dp[i-1][k-1][j-x[i]];
        else dp[i][k][j]=0;
        
      }
    }
  }
  int64_t cnt=0;
  for(int k=1;k<=n;++k){
    cnt+=dp[n][k][a*k];
  }
  cout<<cnt;
}

Measured memory_bytes: 64128
def selectionSort(a):
    count = 0
    for i in range(len(a)):
        mini = i
        for j in range(i,len(a)):
            if a[j] < a[mini]:
                mini = j
        if i != mini:
            ret = a[i]
            a[i] = a[mini]
            a[mini] = ret
            count += 1
    print(" ".join(map(str,a)))
    print(count)
n = int(input())
a = list(map(int,input().split()))
selectionSort(a)

Measured memory_bytes: 7672
#include <stdio.h>
#include <bitset>
#define reg register
std::bitset<4000005> f;
int n,m,a;
int main() {
	reg int i;
	scanf("%d",&n);m=0;
	f[0]=1;
	for(i=0;i<n;++i) {
		scanf("%d",&a);
		f|=f<<a;m+=a;
	}
	for(i=(m+1)>>1;;++i) if(f[i]) {
		printf("%d",i);
		break;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i<N;i++){
	cin >> a[i];
}
	int b[N];
	b[0]=0;
	while(a[0]%2 == 0){
	a[0]=a[0]/2;
	b[0]=b[0]+1;
}
	for(int j=1;j<N;j++){
	b[j]=0;
	while(a[j]%2 == 0){
	a[j]=a[j]/2;
	b[j]=b[j]+1;
}
	if(b[j-1]<b[j]){
	b[j]=b[j-1];
}
}
	cout << b[N-1] << endl;
return 0;
}



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

int main(){
    ll n;
    cin>>n;

    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }

    n/=2;
    ll ans=0;
    ll x=5;
    while(1){
        if(n/x==0) break;
        ans+=n/x;
        x*=5;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3552
package main

import (
	"fmt"
)

func sort(s []string) []string {
	for i := len(s); i > 0; i-- {
		for j := 0; j < i - 1; j++ {
			if s[j] > s[j+1] {
				s[j], s[j+1] = s[j+1], s[j]
			}
		} 
	}
	return s
}

func main() {
	var n, l int
	fmt.Scan(&n, &l)

	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	ss := sort(s)
	var ret string
	for i := 0; i < n; i++ {
		ret += ss[i]
	}

	fmt.Println(ret)
}

Measured memory_bytes: 1280
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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 INF = 1e9;
const long long LINF = 1e18;

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

    int minVal = INF;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int Pi;
        cin >> Pi;

				if (minVal >= Pi) {
            ans++;
        }
        minVal = min(minVal, Pi);

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

int n;

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

ll nibutan(ll le, ll ri, ll ba, vector<ll> &da,vector<ll> &a) {
	if (ri - le == 1) {
		return ri;
	}
	ll  mi = (le + ri) / 2;
	ll cou = 0;
	rip(i, n, 0) {
		cou += min(mi/da[i],a[i]);
	}
	if (cou < ba) {
		return nibutan(mi, ri, ba, da,a);
	}
	else {
		return nibutan(le, mi, ba, da,a);
	}
}

int main() {
	ll k, ba = 0;
	cin >> n >> k;
	vector<ll> a(n), f(n);
	rip(i, n, 0) {
		cin >> a[i];
		ba += a[i];
	}
	rip(i, n, 0) {
		cin >> f[i];
	}
	ll ans;
	sort(all(a));
	sort(all(f));
	reverse(all(a));
	if (ba - k > 0) {
		ans = nibutan(0, ll(1000000000001), ba - k, f,a);
	}
	else {
		ans = 0;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3328
inf = 10**9 + 7
n = int(input())
nodes = list(map(int, input().split()))
dp = [inf] * n

dp[0] = 0


for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1]+abs(nodes[i]-nodes[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2]+abs(nodes[i]-nodes[i-2]))

print(dp[n-1])


Measured memory_bytes: 13928
input_list = [int(input()) for i in range(5)]
k = int(input())
for i in range(1, 5):
    if abs(input_list[0] - input_list[i] ) > k:
        print(":(")
        exit()
for i in range(2, 5):
    if abs(input_list[1] - input_list[i]) > k:
        print(":(")
        exit()
for i in range(3, 5):
    if abs(input_list[2] - input_list[i]) > k:
        print(":(")
        exit()
for i in range(4, 5):
    if abs(input_list[3] - input_list[i]) > k:
        print(":(")
        exit()
print("Yay!")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x,p;
    cin>>x;
    p=100;
    int ans=0;
    while(p<x)
    {
        p+=(p)/100;
        ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	if (s[0] == 'A' && s[1] == 'B')
		cout << "Yes\n";
	else
	if (s[0] == 'B' && s[1] == 'A')
		cout << "Yes\n";
	else
	if (s[1] == 'B' && s[2] == 'A')
		cout << "Yes\n";
	else
	if (s[1] == 'A' && s[2] == 'B')
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sz5 100005

ll BIT[sz5*5], sum[sz5*5];

void update(ll idx, ll n, ll val){
	while(idx<=n){
		BIT[idx]+=val;
		idx+=(idx&(-idx));
	}
}

ll query(ll idx){
	ll ans=0;
	while(idx){
		ans+=BIT[idx];
		idx-=(idx&(-idx));
	}
	return ans;
}

int main() {
	FAST

	ll n,q,la,lb,num;
	cin>>n>>q;
	for(la=1;la<=n;la++){
		cin>>num;
		sum[la]=sum[la-1]+num;
		// update(la, n, num);
	}

	while(q--){
		ll ch, a, b;
		cin>>ch>>a>>b;

		if(ch==0)
			update(a+1, n, b);
		else
			cout<<query(b)-query(a)+sum[b]-sum[a]<<endl;
	}

	return 0;
}

Measured memory_bytes: 12148
#include <bits/stdc++.h>
using namespace std;
int seen[100007]={};
void dfs(int p,vector<vector<int>> &g){
    seen[p] = 1;
    for(auto i:g[p]){
        if(seen[i]==1) continue;
        dfs(i,g);
    }
}
int main(void){
    int n,m,ans=0;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        if(seen[i]) continue;
        dfs(i,g);
        ans++;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin >> n;
    ll i,j;
    ll sum=0;
    for(i=1;i<=n;i++){
        ll h=0;
        ll num=i;
        while(num>0){
            h++;
            num/=10;
        }
        if(h%2!=0)sum++;
    }
    cout << sum << endl;
    return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

signed main(){
	int n;
	cin>>n;
	int a[100];
	rep(i,n)cin>>a[i];
	int m=0;
	int index=1;
	rep(i,n){
		if(abs(a[i])>=m){
			m=abs(a[i]);
			index=i;
		}
	}
	int cnt=0;
	vector<pair<int,int>> ans;
	rep(i,n){
		a[i]+=a[index];
		ans.push_back(make_pair(index,i));
		cnt++;
	}
	if(a[index]>=0){
		rep(i,1,n){
			a[i]+=a[i-1];
			ans.push_back(make_pair(i-1,i));
			cnt++;
		}
	}else{
		for(int i=n-2;i>=0;i--){
			a[i]+=a[i+1];
			ans.push_back(make_pair(i+1,i));
			cnt++;
		}
	}
	cout<<cnt<<endl;
	rep(i,ans.size()){
		cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
	}
	rep(i,n)cerr<<a[i]<<" ";
	cerr<<endl;
}

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

const long long N = 50;

int main() {
  long long K;
  cin >> K;

  long long ans[N];
  for (long long i = 0; i < N; i++) {
    ans[i] = i + (K - 1) / N;
  }

  for (long long i = N - (K - 1) % N - 1; i < N; i++) {
    ans[i]++;
  }

  cout << N << endl;
  for (long long i = 0; i < N - 1; i++) {
    cout << ans[i] << ' ';
  }
  cout << ans[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N, M, cha[111111];
int main(){
    cin>>N>>M;
    int l, r;
    for(int i = 1;i <= M; i++){
        scanf("%d%d", &l, &r);
        cha[l]++;
        cha[r+1]--;   
    }
    for(int i = 1;i <= 100000; i++)cha[i] = cha[i-1] + cha[i];
    int ans = 0;
    for(int i = 1;i <= N; i++)if(cha[i] == M)ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
string its[44000];
map<string, int>M;
int dp[102][44000];
vector<int>G[44000];
signed main() {
	int h, w, K; cin >> h >> w >> K;
	vector<int>V;
	rep(i, w)V.push_back(i + 1);
	int cnt = 0;
	do {
		string s;
		rep(i, V.size()) {
			s.push_back(('0' + V[i]));
		}
		M[s] = cnt;
		its[cnt] = s;
		cnt++;
	} while (next_permutation(V.begin(), V.end()));
	dp[0][0] = 1;

	for (int i = 0; i < 1 << (w - 1); i++) {
		vector<int>v;
		int flg = 0;
		rep(j, w - 2) {
			if (i&(1 << j) && i&(1 << (j + 1)))flg++;
		}
		if (flg)continue;
		else {
			rep(j, w - 1) {
				if (i&(1 << j))v.push_back(j);
			}
			rep(j, cnt) {
				string ns = its[j];
				rep(k, v.size()) {
					swap(ns[v[k]], ns[v[k] + 1]);
				}
				G[j].push_back(M[ns]);
			}
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 0; j < cnt; j++) {
			rep(k, G[j].size()) {
				dp[i][G[j][k]] += dp[i - 1][j];
				dp[i][G[j][k]] %= mod;
			}
		}
	}
	int ans = 0;
	rep(i, cnt) {
		if (its[i][0] == (char)('0' + K)) {
			ans += dp[h][i];
			ans %= mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 63104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n + 1);
	rep1(i, n) {
		cin >> a[i];
	}
	V b(n + 1, 0);
	int cnt = 0;
	for (int i = n; i > 0; i--) {
		int m2 = 0;
		for (int j = i + i; j <= n; j += i) {
			m2 ^= b[j];
		}
		b[i] = m2 ^ a[i];
		if (b[i]) cnt++;
	}
	printf("%d\n", cnt);
	rep1(i, n) if (b[i]) printf("%d ", i);
	printf("\n");
	return 0;
}

Measured memory_bytes: 2432
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        var s = Console.ReadLine();
        var c = s[s.Length - 1];
        var set = new HashSet<string> { s };

        for (int i = 1; i < n; i++)
        {
            s = Console.ReadLine();
            if (c != s[0] || !set.Add(s))
            {
                Console.WriteLine("No");
                return;
            }
            c = s[s.Length - 1];
        }

        Console.WriteLine("Yes");
    }
}


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

using namespace std;
using ll = long long;

char G[105][105];

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

    bool ans = true;
    int time = 0, curx = 0, cury = 0;
    for (int i = 0; i < N; ++i) {
        int t, x, y;
        cin >> t >> x >> y;

        int dt = t - time;
        int distance = abs(x - curx) + abs(y - cury);
        if (distance > dt || distance % 2 != dt % 2) {
            ans = false;
            break;
        }

        time = t;
        curx = x;
        cury = y;
    }

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

// 1-indexed
struct BIT {
    vector<int> data;
    int size;
    BIT(int n): size(n), data(n, 0) {}
    void add(int i, int x) {
        while (i <= size) {
            data[i] += x;
            i += i & -i;
        }
    }
    int sum(int i) {
        int ret = 0;
        while (i > 0) {
            ret += data[i];
            i -= i & -i;
        }
        return ret;
    }
};

signed main() {
    int n,m;
    cin>>n>>m;
    vector<pii> range(n);
    cin>>range;

    vector<vector<int>> len(m+1);
    vector<int> cnt(m+1,0);
    REP(i,n) {
        int l=range[i].second-range[i].first+1;
        len[l].push_back(i);
        cnt[l]++;
    }
    REP(i,m) cnt[i+1]+=cnt[i];

    int k=1;
    BIT bit(m+2);
    REPF(d,1,m+1) {
        int ans=cnt[m]-cnt[d-1];
        while(k<=m && k<d) {
            FORE(i,len[k]) {
                int l=range[i].first, r=range[i].second;
                bit.add(l,1);
                bit.add(r+1,-1);
            }
            k++;
        }
        REP(i,m) {
            if(d*i>m) break;
            ans+=bit.sum(d*i);
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 13824
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

/*
void debug(int v){cout << v << endl;}
*/
void debug(int u,int v, int r){
  cout<<u<<" "<<v<<" "<<r<<endl;
}

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

  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c & c == 1) {cout << 0 << endl; return 0;}
  if(a == b && b == c) {cout << -1 << endl; return 0;}
  int ans = 0;
  while(true){
    if(a%2 || b%2 || c%2) break;
    int tmp[3];
    tmp[0] = a/2; tmp[1] = b/2; tmp[2] = c/2;
    a = tmp[1]+tmp[2];
    b = tmp[0]+tmp[2];
    c = tmp[0]+tmp[1];
    //debug(a, b, c);
    ans++;
  }  
  cout << ans << endl;
  
  return 0;
}


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

int main() {
    string str;
    cin >> str;
    stack<int> my_stack;
    for (int i=0; i<str.length(); i++) {
        if ( str[i] == '0' ) {
            my_stack.push(0);
        } else if (str[i] == '1') {
            my_stack.push(1);
        } else if (my_stack.size() > 0){
            my_stack.pop();
        }
    }
    int stack_size = my_stack.size();
    int array[stack_size];
    for (int i=0; i<stack_size; i++) {
        array[i] = my_stack.top();
        my_stack.pop();
    }
    for (int i=stack_size-1; i>=0; i--) {
        cout << array[i];
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 111111;
vector<int> a[N];
long long cnt[N];
 
long long dfs(int v, int p = -1) {
if (a[v].size() == 1) {
return cnt[v];
}
long long mx = 0;
long long sum = 0;
for (int x : a[v]) { if (x == p) continue; long long mn = dfs(x, v); mx = max(mx, mn); sum += mn; }
int num_sm = (sum - max(sum % 2, 2 * mx - sum)) / 2;
if (sum - num_sm <= cnt[v] && sum >= cnt[v]) return sum - 2 * (sum - cnt[v]); else {
puts("NO");
exit(0);
}
}
 
int main() { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> cnt[i];
for (int i = 0; i < n - 1; ++i) { int u, v; cin >> u >> v; --u, --v; a[u].push_back(v); a[v].push_back(u); }
int root = 0;
if (n == 2) {
if (cnt[0] == cnt[1]) puts("YES"); else puts("NO"); return 0;
}
while (a[root].size() == 1) ++root;
if (dfs(root)) puts("NO"); else puts("YES"); return 0;
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<ll> divisor(ll n){
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0){
      ret.push_back(i);
      if(i!=n/i) ret.push_back(n/i);
    }
  }
  //sort(ret.begin(), ret.end());
  return ret;
}

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

  vector<ll> v = divisor(N);
  ll ret = N-1;
  rep(i,v.size()){
    ll x = v[i];
    ll y = N/x;

    ret = min(ret, x-1 + y-1);
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for ( j = p; j < r; j++ ) {
        if ( A[j] <= x ) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

int main(void) {
    int i, q;

    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

    q = partition(0, n - 1);

    for ( i = 0; i < n; i++ ) {
        if ( i ) printf(" ");
        if ( i == q ) printf("[");
        printf("%d", A[i]);
        if ( i == q ) printf("]");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2128
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val dist = Array(n){IntArray(n){99999999}}
    val edge =(1..m).map{
        val (a,b,c) = readLine()!!.split(" ").map { it.toInt() }
        dist[a-1][b-1]=c
        dist[b-1][a-1]=c
        c*n*n+(a-1)*n+(b-1)
    }
    for (i in 0..n-1)dist[i][i]=0
    for(k in 0..n-1)for(i in 0..n-1)for(j in 0..n-1)
        dist[i][j] = Math.min(dist[i][j], dist[i][k]+dist[k][j])

//    dist.forEach { println(it.joinToString(",")) }
    val ans = edge.count{
        val u=it%(n*n)/n
        val v=it%n
        val w=it/(n*n)
        for(s in 0..n-1)for(t in 0..n-1){
            if(dist[s][u]+w+dist[v][t]==dist[s][t]) return@count false
        }
        return@count true
    }

    println(ans)
}

Measured memory_bytes: 38456
n, m = map(int, input().split())
h = list(map(int, input().split()))
maxh = []
for height in h:
    maxh.append(0)
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    maxh[a] = max(maxh[a], h[b])
    maxh[b] = max(maxh[b], h[a])
g = 0
for height, maxheight in zip(h, maxh):
    if height > maxheight:
        g += 1
print(g)

Measured memory_bytes: 20132
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int enc(int x, int y) {
	return x + y * 3;
}

int _enc(int a, int b, int c, int d) {
	return (a << 9) + (b << 6) + (c << 3) + d;
}

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector< vector<bool> > dp(9, vector<bool>(4096));
		dp[4][_enc(1, 1, 1, 1)] = true;
		while (N--) {
			vector< vector<bool> > v(3, vector<bool>(3, true));
			for (int y = 0; y < 4; y++)
			for (int x = 0; x < 4; x++) {
				int f; cin >> f;
				if (!f) continue;
				for (int _y = 0; _y < 3; _y++)
				for (int _x = 0; _x < 3; _x++)
					if (x - _x >= 0 && x - _x < 2 && y - _y >= 0 && y - _y < 2)
						v[_y][_x] = false;
			}
			vector< vector<bool> > _dp(9, vector<bool>(4096));
			for (int y = 0; y < 3; y++)
			for (int x = 0; x < 3; x++) {
				if (!v[y][x]) continue;
				for (int a = 0; a < 7; a++)
				for (int b = 0; b < 7; b++)
				for (int c = 0; c < 7; c++)
				for (int d = 0; d < 7; d++) {
					int i = enc(x, y), j = _enc(a, b, c, d);
					if (!dp[i][j]) continue;
					for (int _y = 0; _y < 3; _y++)
					for (int _x = 0; _x < 3; _x++) {
						if (_x != x && _y != y) continue;
						int _a = (_x == 0 && _y == 0 ? 0 : a + 1);
						int _b = (_x == 2 && _y == 0 ? 0 : b + 1);
						int _c = (_x == 0 && _y == 2 ? 0 : c + 1);
						int _d = (_x == 2 && _y == 2 ? 0 : d + 1);
						int _i = enc(_x, _y), _j = _enc(_a, _b, _c, _d);
						_dp[_i][_j] = true;
					}
				}
			}
			dp = _dp;
			/*
			int ok = 100;
			for (int y = 0; y < 3; y++)
			for (int x = 0; x < 3; x++)
			for (int a = 0; a < 7; a++)
			for (int b = 0; b < 7; b++)
			for (int c = 0; c < 7; c++)
			for (int d = 0; d < 7; d++) {
				int i = enc(x, y), j = _enc(a, b, c, d);
				if (dp[i][j]) ok = min(ok, a);
			}
			cout << ok << endl;
			*/
		}
		bool ok = false;
		for (int y = 0; y < 3; y++)
		for (int x = 0; x < 3; x++)
		for (int a = 0; a < 7; a++)
		for (int b = 0; b < 7; b++)
		for (int c = 0; c < 7; c++)
		for (int d = 0; d < 7; d++) {
			int i = enc(x, y), j = _enc(a, b, c, d);
			if (dp[i][j]) ok = true;
		}
		cout << (ok ? 1 : 0) << endl;
	}
}

Measured memory_bytes: 1232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String str = input.readLine();
		int n = Integer.parseInt(str);
		ArrayList<Integer> list = new ArrayList();
		int sum = 0;
		int temp;
		for (int i = 0; i < n; i++) {
			str = input.readLine();
			temp = Integer.parseInt(str);
			sum = sum + temp;
			if(temp % 10 != 0){
				list.add(temp);
			}
		}

		if(list.size() == 0){
			sum = 0;
		}else{
			Collections.sort(list);
			int j = 0;
			while (sum % 10 == 0 && j < list.size()) {
				sum = sum - list.get(j);
				j++;
			}
		}

		System.out.println(sum);

	}
}


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

int n, m, x, y, cnt = 0;
vector<pair<int, int>> v;

bool asc(pair<int, int> l, pair<int, int> r) {
  if(l.second < r.second)
    return 1;
  else if(l.second == r.second && l.first < r.first)
    return 1;
  return 0;
}
void solve();

int main() {
  int i;
  cin >> n >> m;
  for(i = 0; i < m; ++i) {
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end(), asc);
  solve();
  cout << cnt << endl;
  return 0;
}
void solve() {
  int now = v[0].second;
  int i;
  cnt = 1;
  for(i = 1; i < v.size(); ++i) {
    if(v[i].first < now)
      continue;
    else {
      ++cnt;
      now = v[i].second;
    }
  }
}

Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = int(input())
div = divisors(n)
div2 = divisors(n-1)

ans = 0
for d in div[1:]:
    tmp = n
    while tmp % d == 0:
        tmp //= d
    if tmp % d == 1:
        ans += 1

print(ans + len(div2) - 1)

Measured memory_bytes: 3316
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  h,w,i,j,count,y,sw,m,dist,poi:Integer;
  n,x:int64;
  a,b,c,d:array of Integer;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);
    for i := 1 to trunc(sqrt(n)) do begin
      if n mod i = 0 then
        x:=n div i;
    end;
    Writeln(length(IntToStr(x)));

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=30;
int n;
char s[maxn];
int main(){
    int x,y;
    cin>>n;
    cout<<0<<endl;
    cin>>s;
    if (s[0]=='V') return 0;
    if (s[0]=='M') x=1;else x=0;
    cout<<n-1<<endl;
    cin>>s;
    if (s[0]=='V') return 0;
    if (s[0]=='M') y=1;else y=0;
    int l=0,r=n-1;
    while (l<r){
        int mid=(l+r+1)>>1,tmp;
        cout<<mid<<endl;
        cin>>s;
        if (s[0]=='V') return 0;
        if (s[0]=='M') tmp=1;else tmp=0;
        if ( (((mid-l)%2==1)&&(tmp!=x)) || (((mid-l)%2==0)&&(tmp==x)) ) {
            l=mid;x=tmp;
        }
        else {
            r=mid;
        }
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
struct card{
	char moyo;
	int value;
};
int main(void){
	int n;
	int i,j;
	int minj;
	card a[37],b[37];
	int flg;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i].moyo>>a[i].value;
		b[i].moyo=a[i].moyo;
		b[i].value=a[i].value;
	}
	for(i=0;i<n;i++){
		for(j=n-1;j>=i+1;j--){
			if(a[j].value<a[j-1].value){
				swap(a[j].value,a[j-1].value);
				swap(a[j].moyo,a[j-1].moyo);
			}
		}
	}
	for(i=0;i<n;i++){
		minj=i;
		for(j=i;j<n;j++){
			if(b[j].value<b[minj].value){
				minj=j;
			}
		}
		swap(b[i].value,b[minj].value);
		swap(b[i].moyo,b[minj].moyo);
	}
	
	for(i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<a[i].moyo<<a[i].value;
	}
	cout<<endl;
	cout<<"Stable"<<endl;
	flg=1;
	for(i=0;i<n;i++){
		if(!(a[i].value==b[i].value&&a[i].moyo==b[i].moyo)){
			flg=0;
		}
	}
	for(i=0;i<n;i++){
		if(i)	cout<<" ";
		cout<<b[i].moyo<<b[i].value;
	}
	cout<<endl;
	cout<<((flg)?"Stable":"Not stable")<<endl;
	return 0;
}
	

	

			


Measured memory_bytes: 3096
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    else{
        if(S.substr(0, N/2) == S.substr(N/2, N/2)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int left = 0;
    int right = 0;
    int ans_left = 0;
    int ans_right = 0;
    rep(i,N){
        if (S[i] == '(') left++;
        if (S[i] == ')') right++;
        ans_left = max(ans_left, right - left);
    }
    left += ans_left;
    ans_right = left - right;
    rep(i,ans_left){
        S = "(" + S;
    }
    rep(i,ans_right){
        S = S + ")";
    }
    cout << S << endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int ll;
ll MOD = 1 << 30;

// ?????????????????????
// Verified: TopCoder SRM 704 Div.2 (ModEquationEasy)
// ???????????? ??¨ ?´????(??°??????????????????)

// Matrix Library Begin (C++11)

template <typename T>
using Matrix = vector< vector<T> >;

template <typename T>
void init_mat(Matrix<T> &A, int h, int w) {
    A.resize(h, vector<T>(w, 0));
}

template <typename T>
Matrix<T> calc_mat(Matrix<T> A, Matrix<T> B) {
    Matrix<T> C(A.size(), vector<T>(B[0].size()));
    for(int i=0; i<A.size(); i++) {
        for(int k=0; k<B.size(); k++) {
            for(int j=0; j<B[0].size(); j++) {
                // C[i][j] += A[i][k] * B[k][j]; // mod??????
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; // mod??????
            }
        }
    }
    return C;
}

template <typename T>
Matrix<T> mat_pow(Matrix<T> A, ll n) {
    Matrix<T> B(A.size(), vector<T>(A.size()));
    for(int i=0; i<A.size(); i++) B[i][i] = 1;
    while(n > 0) {
        if(n & 1) B = calc_mat(B, A);
        A = calc_mat(A, A);
        n >>= 1;
    }
    return B;
}

// Matrix Library End

int N, M, A, B, C, T;
int main() {
    while(1) {
        scanf("%d%d%d%d%d%d", &N, &M, &A, &B, &C, &T);
        if(N == 0) break;

        MOD = M;
        Matrix<ll> mat, vec;
        init_mat(mat, N, N);
        init_mat(vec, N, 1);

        for(int i=0; i<N; i++) {
            scanf("%lld", &vec[i][0]);
        }

        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                if(i-1 == j) mat[i][j] = A;
                if(i   == j) mat[i][j] = B;
                if(i+1 == j) mat[i][j] = C;
            }
        }

        Matrix<ll> ret = calc_mat(mat_pow(mat, T), vec);
        for(int i=0; i<N; i++) {
            if(i != 0) printf(" ");
            printf("%lld", ret[i][0]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2884
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b;
  
  if(abs(a-b)%2==1)cout<<"IMPOSSIBLE"<<endl;
  else cout<<abs(a-b)/2+min(a,b)<<endl;
  return 0;
}


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

int main() {
    int times = 0;
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<vector<int> > field(n, vector<int>(n));
        int count = 0;
        for (int i = 0; i < n * 2 - 1; i++) {
            for (int j = 0; j < i + 1; j++) {
                int y = i - j, x = j;
                if (i % 2 != 0) {
                    swap(y, x);
                }
                if (0 <= y && y < n && 0 <= x && x < n) {
                    field[y][x] = ++count;
                }
            }
        }
        cout << "Case " << ++times << ":" << endl;
        for (int y = 0; y < n; y++) {
            for (int x = 0; x < n; x++) {
                printf("%3d", field[y][x]);
            }
            cout << endl;
        }
    }
}

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

int main()
{
	int N;
	cin >> N;
	int l, r,a=0;
	for (int i = 0; i < N; ++i)
	{
		cin >> l >> r;
		a += r - l + 1;
	}
	cout << a;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()

string S;

int towhere(int sta, int end){
    end = min((int)S.size()-1, end);
    while(sta+1 <= end){
        if (S[end] == '0') return end;
        end--;
    }
    return -1;
}

int main(){
    int N, M; cin >> N >> M;
    cin >> S;
    reverse(all(S));
    vector<int> step; int now = 0;
    while(now < S.size()-1){
        int tw = towhere(now, now+M);
        if (tw == -1) { cout << -1 << endl; return 0; }
        step.push_back(tw-now);
        now = tw;
    }
    reverse(all(step));
    for(auto& x : step) cout << x << ' ';
}

Measured memory_bytes: 1080
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Text;
namespace AtC_169
{
    class Program
    {

        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] A = Console.ReadLine().Split(' ');
            long num = 1000000000000000000;
            long ans = 1;
            for(long i = 0; i < N; i++)
            {
                if (long.Parse(A[i]) == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            for (long i = 0; i < N; i++)
            {
                try
                {
                    checked
                    {
                        ans = ans * long.Parse(A[i]);
                    }
                }
                catch
                {
                    Console.WriteLine(-1);
                    return;
                }

                if (ans > num)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(ans);
        }
    }

    
}


Measured memory_bytes: 41188