akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int cnt2 = 0, cnt4 = 0;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a % 4 == 0) cnt4++;
        else if (a % 2 == 0) cnt2++;
    }

    if (n / 2 <= cnt4) {
        cout << "Yes" << endl;
    } else {
        if (n - cnt4 * 2 <= cnt2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        double a = sc.nextDouble();
                        double b = sc.nextDouble();
                        double c = Math.toRadians(sc.nextDouble());
                        System.out.println(a * b * Math.sin(c) / 2.);
                        System.out.println((a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(c))));
                        System.out.println(b * Math.sin(c));
                }
        }
}

Measured memory_bytes: 27920
t=int(input())
for j in range(t):
  n,k=map(int,input().split())
  l=list(map(int,input().split()))
  l1=[]
  for i in range(n-1):
      l1.append(l[i+1]-l[i])
  l1=sorted(l1)
  if n<=k:
    print(0)
  else:
    for i in range(k-1):
      del l1[-1]
    s=0
    for i in l1:
        s+=i
    print(s)


Measured memory_bytes: 21848
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	xl := make([]int, n)
	yl := make([]int, n)
	hl := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d", &xl[i], &yl[i], &hl[i])
	}

	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			h := 0
			for i := 0; ; i++ {
				if hl[i] > 0 {
					h = hl[i] + abs(xl[i]-x) + abs(yl[i]-y)
					break
				}
			}
			for i := 0; i < n; i++ {
				if hl[i] != max(h-abs(xl[i]-x)-abs(yl[i]-y), 0) {
					break
				}
				if i == n-1 {
					fmt.Println(x, y, h)
					return
				}
			}
		}
	}
}

func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

func max(x, y int) int {
	if x < y {
		return y
	}
	return x
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {	
	int N, M; cin >> N >> M;
	vvi out(N + 1); // i-ind
	int X, Y, Z;
	rep(i, M) {
		cin >> X >> Y >> Z;
		out.at(X).push_back(Y);
		out.at(Y).push_back(X);
	}	

	int ans = 0;
	vector<bool> r(N + 1);
	queue<int> q;
	rep2(i, 1, N + 1) { // 1-ind		
		if (r.at(i)) continue;
		// debug(i);
		q.push(i); r.at(i) = true;		
		while (q.size()) {
			int u = q.front(); q.pop();
			// debug(u);
			for (int v : out.at(u)) {				
				if (r.at(v)) continue;
				// debug(v);
				q.push(v); r.at(v) = true;				
			}
		}
		ans++;
		// debug(ans);
	}
	
	cout << ans;
}

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

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

    for(int i=0; i<=n-1; i++){
        long long int xmin = c * (n-1-i) + (-d) * i;
        long long int xmax = d * (n-1-i) + (-c) * i;
        if(xmin <= b-a && b-a <= xmax){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    vector<int> cnt(h, 0);
    rep(i, h){
        cin >> s[i];
        rep(j, w){
            cnt[i] += s[i][j] == '#';
        }
    }

    vector< vector<int> > a(h, vector<int>(w, -1));
    int now = 1;
    int f = 0;
    while(cnt[f] == 0){
        ++f;
    }

    REP(i, f, h){
        int tmp = 0;
        rep(j, w){
            if(cnt[i] > 0){
                a[i][j] = now;
                if(s[i][j] == '#'){
                    ++tmp;
                    if(tmp < cnt[i] && now < k){
                        ++now;
                    }
                }
            }else{
                a[i][j] = a[i - 1][j];
            }
        }
        if(cnt[i] > 0){
            ++now;
        }
    }

    rrep(i, f){
        rep(j, w){
            a[i][j] = a[i + 1][j];
        }
    }

    rep(i, h){
        rep(j, w){
            if(j) cout << ' ';
            cout << a[i][j];
        }
        cout << endl;
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 1280
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextFloat() float64 {
	sc.Scan()
	v, _ := strconv.ParseFloat(sc.Text(), 64)
	return v
}

func nextInt() int64 {
	sc.Scan()
	v, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return v
}

func main() {
	sc.Split(bufio.ScanWords)
	N := int(nextInt())
	D := nextFloat()
	ans := 0
	for i := 0; i < N; i++ {
		x := nextFloat()
		y := nextFloat()
		if x * x + y * y <= D * D {
			ans += 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4876
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<62);

int main() {
    long double b;
    cin>>A>>b;
  	b *= 100;
  	B = round(b);
    B *= A;
    cout<<B / 100<<endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #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(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int red=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            red++;
    }
    int last_red=-1;
    int ans=0;
    for(int i=0;i<n;i++)
    {
       if(s[i]=='R' and i>=red)
       {
           ans++;
       }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3748
N = int(input())

def dfs(s, mx):
    if len(s) == N:
        print(s)
    else:
        for c in range(ord("a"),mx+1):
            if c == mx:
                dfs(s+chr(c),mx+1)
            else:
                dfs(s+chr(c),mx)

dfs("",ord("a"))


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    string s;
    cin >> s;
    reverse(all(s));
    REP(i,LEN(s)){
        if(s.substr(i,5)=="maerd" || s.substr(i,5)=="esare") i += 4;
        else if(s.substr(i,6)=="resare") i+= 5;
        else if(s.substr(i,7)=="remaerd") i+= 6;
        else {
            puts("NO");
            return 0;
        }
    }

    puts("YES");
    return 0;
}

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

int main() {
	
	int n,m;
	cin >> n >> m;
	string t;
	for(int i=0; i<n; i++) t+='0';
	map<int,int> a;
	for(int i=1; i<=3; i++) a[i]=-1;
	
	bool flg=1;
	for(int i=0; i<m; i++){
		int s,c;
		cin >> s >> c;
		if(n!=1 && s==1 && c==0) flg=0;
		if(a.at(s)!=-1 && a.at(s)!=c) flg=0;
		a.at(s)=c;
		t.at(s-1)=(char) (c+'0');
	}
	if(n==3 && a.at(1)==-1) t.at(0)='1';
	if(n==2 && a.at(1)==-1) t.at(0)='1';
	if(!flg) cout << "-1" << endl;
	else cout << t << endl;
	
}


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

using namespace std;
typedef long long ll;
typedef long double ld;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
//const ll MAX = 3e5+1;
//const ll INF = 1e18;
//const ld PI = acos(-1L);

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

    ll A;
    ld B;
    cin >> A >> B;
    B *= 100L;
    B += 0.0001L;
    A *= (ll) B;
    out(A / 100LL);

    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, 0); int sum, count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum+=a[i];
  }
  double minimum = (double) sum / (4*m);
  sort(a.begin(), a.end());
  if (a[n-m] >= minimum) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

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


void solve(long long a, long long b, long long c, long long d){
    long long tmp = a * c;
    if(a * d > tmp) tmp = a*d;
    if(b * c > tmp) tmp = b*c;
    if(b * d > tmp) tmp = b*d;
    cout << tmp << endl;
    
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 3680
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]

cnt=0
for i in range(N):
    ans=0
    for j in range(M):
        ans += B[j]*A[i][j]
    if ans+C>0:
        cnt+=1

print(cnt)

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

P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

red_green = [(p, "r") for p in P] + [(q, "g") for q in Q]
red_green.sort()
nc = R
nc.sort()

cnt_r , cnt_g , cnt_n = 0,0,0

ans = 0
while cnt_r + cnt_g + cnt_n < X + Y:

    # 指定の個数食べきっている色は除外
    if cnt_r == X:
        while red_green[-1][1] == "r":
            red_green.pop()
    if cnt_g == Y:
        while red_green[-1][1] == "g":
            red_green.pop()

    # 無色と色付きの得点の高いほうを食べる
    if len(nc) > 0 and nc[-1] > red_green[-1][0]:
        point = nc.pop()
        ans += point
        cnt_n += 1
    else:
        point, color = red_green.pop()
        ans += point
        if color == "r":
            cnt_r += 1
        else:
            cnt_g += 1


print(ans)

Measured memory_bytes: 31052
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(input())
a = list(map(int,input().split()))

x = gcd(a[0],a[1])

if n != 2:
    for i in range(2,n):
        x = gcd(x,a[i])
        
print(x)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
  string s;
  cin>>s;
  if(s=="Sunny")
    cout<<"Cloudy"<<endl;
  else if(s=="Cloudy")
    cout<<"Rainy"<<endl;
  else if(s=="Rainy")
    cout<<"Sunny"<<endl;
}



Measured memory_bytes: 256
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int((p+1)**(1/n))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
int W,H,N;
  cin>>W>>H>>N;
  int maxX=0;
  int minX=W;
  int maxY=0;
  int minY=H;
  for(int i=0;i<N;i++){
  int x,y,a;
    cin>>x>>y>>a;
    if(a==1){
    if(maxX<x)
      maxX=x;
    }
      if(a==2){
      if(x<minX)
        minX=x;
      }
        if(a==3){
        if(maxY<y)
          maxY=y;
        }
          if(a==4){
          if(y<minY)
            minY=y;
          }
  
  }if(minX<=maxX || minY<=maxY)
    cout<<0<<endl;
  else{
  int ans=(minX-maxX)*(minY-maxY);
    cout<<ans<<endl;
  }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int64_t Y;
  cin >> N >> Y;
  
  for(int i = 0; i <= N ; i++){
    for(int j = 0; j <= N - i ; j++){
      if((10000*i + 5000*j + 1000*(N - i - j)) == Y){
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
constexpr long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int b[22][214514];
int c[22][214514];

void print(int n) {
    repr(i,10) {
        rep(j,n) {
            cout << c[i][j] << " ";
        }
        cout<<endl;
    }
} 

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));

    rep(i,22) {
        rep(j,n) {
            if (a[j] & (1ll<<i)) b[i][j]=1;
        }
    }

    rep(i,22) {
        ll cur = n;
        repr(j,214514) {
            c[i][j]=cur;
            if (b[i][j]) cur=j;
        }
    }
    ll ans = 0;

    rep(j,n-1) {
        ll tmp = LINF;
        rep(i,22) {
            if (b[i][j]) tmp = min(tmp,(ll)c[i][j]-j-1);
            else {
                int x = c[i][j];
                tmp = min(tmp,(ll)c[i][x]-j-1);
            }
        }
        // printf("tmp = %lld\n",tmp);
        ans += tmp;
    }
    ans+=n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38656
#include<bits/stdc++.h>
#include<queue>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin>>N>>M;
  vector<int> X;
  int tmp;
  REP(i,M){
    cin>>tmp;
    X.push_back(tmp);
  }
  sort(X.begin(),X.end());
  if(N>=M){
    cout<<"0";
  }else{
    int ans=0;
    int sa=M-N;
    vector<int> Y;
    REP(i,M-1){
      tmp=X[i+1]-X[i];
      Y.push_back(tmp);
    }
    sort(Y.begin(),Y.end());
    int tmp2;
    REP(i,N)tmp2+=Y[M-1-i];
    cout<<X[M-1]-X[0]-tmp2;
  }
  return 0;
}

Measured memory_bytes: 1400
def main():
    g = 0
    n = int(input())
    v = list(map(int,input().split()))
    c = list(map(int,input().split()))
    for i in range(n):
        gain = v[i] -c[i]
        if gain > 0 :
            g += gain
    print(g)


if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >>N;
  int ans=0;
  for(int i=1;i<=N;i+=2){
    int c=0;
    for(int j=1;j<=sqrt(i-1);j++){
      if(i%j==0)c++;
    }
    if(c==4)ans++;
  }
  cout <<ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll f(ll i) {
    int sum = 0;
    while(i) {
        sum += i % 10;
        i /= 10;
    }
    return sum;
}

int main() {
    int a, n, m;
    cin >> a >> n >> m;
    int cnt = 0;
    for(int y = 1; y <= 72; y++) {
        int t = n;
        ll x = 1;
        while(t) {
            x*=(y+a);
            t--;
        }
        if(x <= m && f(x) == y) cnt++; 
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const int MAX = 1010000;
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;
}

long long FAC(int n){
  return fac[n];
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll X,Y;
  cin>>X>>Y;
  ll a=0,b=0;
  REP(i,1000000){
    ll x=X-2*i, y=Y-i;
    if(y==x*2){
      a=i, b=X-2*i;
    }
  }
  if(a==0&&b==0){
    cout<<0<<endl;
  }else{
    COMinit();
    cout<<COM(a+b,b)<<endl;
  }
}


Measured memory_bytes: 23936
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
  
	//文字列から10進数に変換するときはparseIntを使います
	var a = input[0];
	var b = input[1];
	var c = input[2];
	var d = input[3];

    //判定
  	var answer = a * b;
    var tmpA = c * d;
    if (answer < tmpA ) answer = tmpA;

	console.log('%s',answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  int n;
  cin>>n;
  vector<long double> v(n+1);
  for(int i=1;i<=n;i++)
     cin>>v[i];
  
  long double dp[n+1][n+1];
  memset(dp,0,sizeof(dp));
  dp[0][1]=1-v[1];
  dp[1][1]=v[1];
  for(int i=2;i<=n;i++){
    for(int j=0;j<=i;j++){
      if(j-1>=0)
        dp[j][i]=dp[j][i]+dp[j-1][i-1]*v[i];
      dp[j][i]=(dp[j][i]+dp[j][i-1]*(1-v[i]));
    }
  }
  /*for(int i=1;i<=n;i++){
	  for(int j=0;j<=i;j++)
	   cout<<dp[i][j]<<" ";
	  cout<<endl;
  }*/ 
  long double s=0;
  for(int i=n/2+1;i<=n;i++)
   s=s+dp[i][n];
  printf("%0.12Lf\n",s);
}


Measured memory_bytes: 140928
def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

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

LCM = A[0]
for i in range(0,N-1,1):
    LCM = lcm(LCM,A[i+1])
B = [0 for i in range(0,N,1)]
for i in range(0,N,1):
    B[i]= (LCM%MOD)*pow(A[i],MOD-2,MOD)%MOD

ans = 0
for i in range(0,N,1):
    ans = (B[i] + ans)%MOD

print(ans)

Measured memory_bytes: 43484
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    vector<int> a(5);
    rep(i,5) cin >> a.at(i);
    vector<int> b(5);
    rep(i,5){
        b.at(i)=a.at(i)%10;
    }
    rep(i,5){
        if(b.at(i)==0)continue;
        else b.at(i)=10-b.at(i);
    }
    int m=0;
    rep(i,5){
        m=max(m,b.at(i));
    }
    int ans=0;
    rep(i,5){
        ans+=a.at(i)+b.at(i);
    }
    cout << ans-m << endl;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if ((N * A) > B) {
    cout << B << endl;
  } else if ((N * A) < B) {
    cout << N * A << endl;
  } else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <list>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 1000000007
using namespace std;
typedef long long LL;
//typedef pair<int,int> P;
//typedef priority_queue<P, vector<P>, greater<P> > minPQ;
struct edge {int to,cost;};
const int SIZE = 1<<18;

int main() {
	int x,y;
	cin >> x >> y;
	int ans = 0;
	if(x>=0) {
		if(y<x && abs(y)<=abs(x)) {
			if(y<=0) {
				ans = 1+y+x;
			} else {
				ans = 2-y+x;
			}
		} else if(y<x && abs(y)>abs(x)) {
			ans = (-y-x)+1;
		} else {
			ans = y-x;
		}
	} else {
		if(y>x && abs(y)<abs(x)) {
			if(y<=0) {
				ans = y-x;
			} else {
				ans = 1-y-x;
			}
		} else if(y>x && abs(y)>=abs(x)) {
			ans = 1+y+x;
		} else {
			ans = 2+x-y;
		}
	}
	if(x==y) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	str s;
	cin >> s;
	ll sum = 0;
	rep(i, s.size())
	{
		sum += s.at(i) - '0';
	}
	if (sum % 9)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int n;
  while(cin >> n){
    vector<int> h(n); cin >> h;

    bool ans = true;

    h[0] -= 1;

    FOR(i,1,n){
      if(h[i-1] < h[i]){
        --h[i];
      }
    }

    REP(i,n-1){
      if(h[i] > h[i+1]){
        ans = false;
      }
    }
    


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


Measured memory_bytes: 640
a,b=[parse(Int,i) for i in split(readline())]
k = [Int(i) for i=cld(12.5a,1):cld(12.5b,1) if a==fld(0.08i,1) && b==fld(0.1i,1)]
print(length(k)==0 ? -1 : k[1])

Measured memory_bytes: 114132
A = [[], [], []]
A[0] = [int(x) for x in input().split()]
A[1] = [int(x) for x in input().split()]
A[2] = [int(x) for x in input().split()]
N = int(input())

bingo = [[False] * 3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for tate in range(3):
        for yoko in range(3):
            if A[tate][yoko] == b:
                bingo[tate][yoko] = True

def check(bingo):
    for tate in range(3):
        if all(bingo[tate]):
            return True
    for yoko in range(3):
        if bingo[0][yoko] and bingo[1][yoko] and bingo[2][yoko]:
            return True
    if bingo[0][0] and bingo[1][1] and bingo[2][2]:
        return True
    if bingo[0][2] and bingo[1][1] and bingo[2][0]:
        return True
    return False

if check(bingo):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

index = []
while N > 0:
    N -= 1
    digit = N % 26
    index.append(digit)

    N -= digit
    N //= 26



ans = []
change = list("abcdefghijklmnopqrstuvwxyz")

# print(index)
index.reverse()


for i in range(len(index)):
    ans.append(change[index[i]])


print("".join(ans))




Measured memory_bytes: 10896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MOD = 1e9+7;
int n, a, d[3], c, e;
long long ans = 1;
string s;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		c = 0; e = 0;
		rep(i,3) if(d[i] == a) c++,e=i;
		d[e]++;
		ans = ans * c % MOD;
	}
	printf("%lld\n", ans);
}

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

#define fi  first
#define se  second
#define mp  make_pair
#define pb  push_back

typedef long long ll;
typedef queue <int> qi;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef map <string, int> msi;
typedef pair <string, int> psi;
typedef map <string, string> mss;
typedef unsigned long long ull;

const ll mod = 10e9+7;
const double eps = 1e-11;
const double PI = 2 * acos(0.0);

int dp[5001][5001], dp2[5001][5001];

void pre() {
    for (int i = 0; i < 5001; i++) {
        for (int j = 0; j < 5001; j++) {
            dp[i][j] = abs(i - j);
        }
    }

    for (int i = 0; i < 5001; i++) {
        for (int j = 0; j < 5001; j++) {
            dp2[i][j] = abs(i + j);
        }
    }
}

int main() {
    pre();

    int n;
    cin >> n;

    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];

    int sum = abs(arr[0]);
    for (int i = 1; i < n; i++) {
        if (arr[i - 1] < 0 && arr[i] >= 0)
            sum += dp2[ abs(arr[i - 1]) ][ arr[i] ];
        else if (arr[i - 1] >= 0 && arr[i] < 0)
            sum += dp2[ abs(arr[i]) ][ arr[i - 1] ];
        else
            sum += dp[ abs(arr[i - 1]) ][ abs(arr[i]) ];
    }

    if (arr[n - 1] < 0) sum += dp2[ abs(arr[n - 1]) ][0];
    else sum += dp[ abs(arr[n - 1]) ][0];
    // cout << sum << endl;

    for (int i = 0; i < n; i++) {
        int x = arr[i];
        if (i == 0) {
            int t;
            int cr = arr[i];
            int fr = arr[i + 1];

            int ts = sum - dp[abs(cr)][0];

            if (cr < 0 && fr >= 0) t = dp2[ abs(cr) ][fr];
            else if (fr < 0 && cr >= 0) t = dp2[ abs(fr) ][cr];
            else t = dp[ abs(cr) ][ abs(fr) ];

            ts -= t;

            ts += dp[abs(fr)][0];
            cout << ts << endl;
        }
        else if (i == n - 1) {
            int t;
            int bk = arr[i - 1];
            int cr = arr[i];

            if (bk < 0 && cr >= 0) t = dp2[ abs(bk) ][cr];
            else if (cr < 0 && bk >= 0) t = dp2[ abs(cr) ][bk];
            else t = dp[ abs(cr) ][ abs(bk) ];

            int ts = sum - t;
            ts -= dp[abs(cr)][0];
            ts += dp[abs(bk)][0];
            cout << ts << endl;
        }
        else {
            int t;
            int bk = arr[i - 1];
            int fr = arr[i + 1];
            int cr = arr[i];

            if (bk < 0 && cr >= 0) t = dp2[ abs(bk) ][cr];
            else if (cr < 0 && bk >= 0) t = dp2[ abs(cr) ][bk];
            else t = dp[ abs(cr) ][ abs(bk) ];

            int ts = sum - t;
            if (cr < 0 && fr >= 0) t = dp2[ abs(cr)][fr];
            else if (fr < 0 && cr >= 0) t = dp2[ abs(fr) ][cr];
            else t = dp[ abs(cr) ][ abs(fr) ];
            ts -= t;

            if (bk < 0 && fr >= 0) t = dp2[ abs(bk)][fr];
            else if (fr < 0 && bk >= 0) t = dp2[ abs(fr) ][bk];
            else t = dp[ abs(bk) ][ abs(fr) ];

            ts += t;
            cout << ts << endl;
        }
    }
}


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

int main() {

  int n;
  cin >> n;
  string str;
  int l_white=0;
  int r_red = 0;

  cin >> str;
  int w_num=0;
  int r_num = 0;
  for(int i=0 ; i<n ; i++){
    if(str[i]=='R') r_num++;
    else w_num++;
  }

  for(int i=0; i<n; i++){
    if( i<r_num && str[i]=='W') l_white++;
    else if(i >=r_num && str[i]=='R') r_red++;
  }

  if((w_num==0) || (r_num==0)) cout << "0" << endl;
  else {
    int min_num = min(l_white, r_red);
    cout << min_num + (l_white-min_num) + (r_red-min_num) << endl;
  }
  return 0;
  
}


Measured memory_bytes: 3696
def main():
    n = int(input())
    cards = []
    for _ in range(n):
        cards.append(int(input()))
    cards.append(0)
    answer = 0
    tmp = 0
    for i in range(n + 1):
        if cards[i]:
            tmp += cards[i]
        else:
            answer += tmp // 2
            tmp = 0
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7196
import sys

N, M, Q = map(int, sys.stdin.readline().split())

S = [[0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    l, r = map(int, sys.stdin.readline().split())
    S[l][r] += 1

for l in range(N):
    for r in range(N+1):
        S[l+1][r] += S[l][r]

for l in range(N+1):
    for r in range(N):
        S[l][r+1] += S[l][r]

for _ in range(Q):
    p, q = map(int, sys.stdin.readline().split())
    ans = S[q][q] - S[q][p-1] - S[p-1][q] + S[p-1][p-1]
    print(ans)

Measured memory_bytes: 15268
#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define int long long
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define rep(n) for(int i=0;i<(n);i++)
#define rrep(n) for(int i=(n)-1;i>=0;i--)
#define mem(a,b) memset((a),(b),sizeof (a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define INF (long long) 1e18
#define MOD 1000000007


void solve(){
      int n;
      cin>>n;
      map<string,int> m;
      for(int i=0;i<n;i++){
            string s;
            cin>>s;
            sort(all(s));
            m[s]++;
      }
      int ans = 0;
      for(auto x = m.begin();x!=m.end();x++){
            //cout<<(*x).ff<<" ";
            int num = (*x).ss;
            ans += num*(num-1)/2;
            
      }
      cout<<ans<<endl;
}

int32_t main(){
      FAST
      int t=1;
      //cin>>t;
      while(t--)
            solve();
      return 0;
}




Measured memory_bytes: 11408
#%%
import itertools

n = int(input())
l = list(itertools.product(range(2), repeat=n))
s = [[] for _ in range(n)]

for i in range(n):
    tmp = int(input())
    for j in range(tmp):
        tmp_list = list(map(int, input().split()))
        s[i].append(tmp_list)

#print(s)

ans = 0
for i in range(len(l)):
    #print(' ', l[i])
    tmp = 0
    tmp_list = l[i]
    flag = True
    for j in range(n):
        if tmp_list[j] == 0:
            pass
        else:
            tmp += 1
            for k in range(len(s[j])):
                #print(tmp_list[s[j][k][0]-1], s[j][k][1])
                if tmp_list[s[j][k][0]-1] == s[j][k][1]:
                    pass
                else:
                    flag = False
                    break
    if flag:
        ans = max(ans, tmp)
    #print('ans', ans)

print(ans)

Measured memory_bytes: 49644
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if((x-r)<0||(y-r)<0||(x+r)>W||(y+r)>H){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<vector<int> > g;
int res = 0;
vector<int> dp;
vector<int> X;
bool ok = true;


int dfs(int a) {
	if (X[a] == 1) {
		ok = false;
		return 0;
	}
	
	if (dp[a] == -1) {
		X[a] = 1;
		dp[a] = 1;
		for (int i : g[a]) {
			dp[a] = max(dfs(i) + 1, dp[a]);
		}
		X[a] = 2;
	}
	
	//cerr << a << " " << dp[a] << endl;
	res = max(res, dp[a]);
	return dp[a];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	g.resize((N * (N - 1)) / 2);
	dp.resize(g.size(), -1);
	X.resize(g.size(), 0);
	int c = 0;
	int a;
	vector<vector<int> > idx(N, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			idx[i][j] = idx[j][i] = c;
			c++;
		}
	}
	for (int i = 0; i < N; i++) {
		int b = -1;
		for (int j = 0; j < N - 1; j++) {
			cin >> a; a--;
			if (b != -1) {
				g[b].push_back(idx[i][a]);
				//cerr << i << " " << a << " " << b << " " << idx[i][a] << endl;
			}
			b = idx[i][a];
		}
	}

	for (int i = 0; i < g.size(); i++) {
		if (X[i] == 0) {
			dfs(i);
		}
	}
	if (ok) {
		cout << res << endl;
	}
	else {
		cout << -1 << endl;
	}

}

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

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> anss, anst;
  while(n){
    vector<int> s(n) ,t(m), mini(2,300);
    int sums = 0, sumt = 0;
    for(int i = 0; i < n ; i++){
      cin >> s[i];
      sums += s[i];
    }
    for(int i = 0; i < m ; i++){
      cin >> t[i];
      sumt += t[i];
    }
    if(sums == sumt){
      for(int i = 0 ; i < n ; i++){
        for(int j = 0; j < m ; j++){
          if(s[i] == t[j] && mini[0] > s[i]){
            mini[0] = s[i];
            mini[1] = t[j];
          }
        }
      }
    }
    else{
      for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
          if( 2 * (s[i] - t[j]) == sums - sumt && mini[0] + mini[1] > s[i] + t[j] ){
            mini[0] = s[i];
            mini[1] = t[j];
          }
        }
      }
    }
    anss.push_back(mini[0]);
    anst.push_back(mini[1]);
    cin >> n >> m;
  }
  for(int i = 0 ; i < (int)anss.size() ; i++){
    if(anss[i] == 300) cout << -1 << endl;
    else cout << anss[i] << " " << anst[i] << endl;
  }
}



Measured memory_bytes: 2996
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <utility>
#include <iomanip>
#include <climits>
using namespace std;
#define ll long long
#define MOD 1000000007
#define MAX 1000000000000000000
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define f first
#define s second
#define Test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
int main() 
{
	fast_io;
	ll n,i;
	string s,s1,s2;
	cin>>n>>s;
	if(n&1) cout<<"No";
	else
	{
	    ll f=1;
	    for(i=0;i<n/2;i++)
	    {
	        if(s[i]!=s[(n/2)+i])
	        {
	            f=0;
	            break;
	        }
	    }
	    if(f) cout<<"Yes";
	    else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define int long long
#define N 200010
using namespace std;
inline int read()
{
	int neg=1,num=0;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')neg=-1;
	for(;isdigit(c);c=getchar())num=(num<<1)+(num<<3)+c-'0';
	return neg*num;
}
struct node
{
	int l,r;
}q[N];
int n,ans,pre[N][2],suf[N][2];
bool cmp1(node x,node y){return (x.r^y.r)?x.r<y.r:x.l>y.l;}
bool cmp2(node x,node y){return (x.r^y.r)?x.r<y.r:x.l<y.l;}
inline void work()
{
	pre[1][0]=q[1].l;pre[1][1]=q[1].r;suf[n][0]=q[n].l;suf[n][1]=q[n].r;
	for(int i=2  ;i<=n;i++)pre[i][0]=max(pre[i-1][0],q[i].l),pre[i][1]=min(pre[i-1][1],q[i].r);
	for(int i=n-1;i>=1;i--)suf[i][0]=max(suf[i+1][0],q[i].l),suf[i][1]=min(suf[i+1][1],q[i].r);	
	for(int i=1;i<=n-1;i++)ans=max(ans,max(0ll,pre[i][1]-pre[i][0]+1)+max(0ll,suf[i+1][1]-suf[i+1][0]+1));
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)q[i].l=read(),q[i].r=read();
	sort(q+1,q+n+1,cmp1);work();
	sort(q+1,q+n+1,cmp2);work();
	
	for(int i=1;i<=n;i++)
	{
		int mi=-2147483647,mx=2147483647;
		if(i>1)mi=max(pre[i-1][0],mi),mx=min(pre[i-1][1],mx);
		if(i<n)mi=max(suf[i+1][0],mi),mx=min(suf[i+1][1],mx);
		ans=max(ans,q[i].r-q[i].l+1+max(0ll,mx-mi+1));
	}
	int T=500;
	while(T--)
	{
		for(int i=1;i<=n;i++)
		{
			int j=i;
			while(q[j+1].r==q[j].r)j++;
			random_shuffle(q+i,q+j+1);
			i=j;
		}
		work();
	}
	printf("%lld\n",ans);
	return 0;
}
/*
5
1 20
2 20
3 20
4 20
5 20
*/



Measured memory_bytes: 8452
#include <bits/stdc++.h>
#define MAXS 10
using namespace std;

char s[MAXS];
int ans;

int main() {
	scanf("%s", s + 1);
	for (register int i = 1, i_lim = strlen(s + 1); i <= i_lim; ++i)
		s[i] == '+' ? ++ans : --ans;
	printf("%d", ans);
	return 0;
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
  	
  	int total = 0;
    if(C > A+B+1) total += A+B+1;
  	else total += C;
	
  	cout << B + total << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(){
     int t,i,j,n,k,a,b,c;
     scanf("%d%d%d",&a,&b,&c);
     if(a+b+c>21) printf("bust");
     else printf("win");
     return 0;
}


Measured memory_bytes: 128
import sys
from heapq import heappush, heappop
sys.setrecursionlimit(100000)
INF = 10 ** 10

direct = ((0, -1), (0, 1), (-1, 0), (1, 0))

def dist(fr, to, mp):
  que = []
  heappush(que, (0, fr))
  visited = [[False] * len(mp[0]) for _ in range(len(mp))]
  visited[fr[1]][fr[0]] = True
  while que:
    d, point = heappop(que)
    x, y = point
    for dx, dy in direct:
      nx, ny = x + dx, y + dy
      if (nx, ny) == to:
        return d + 1
      if not visited[ny][nx] and mp[ny][nx] != "x":
        visited[ny][nx] = True
        heappush(que, (d + 1, (nx, ny)))
  else:
    return -1

def my_hash(rest):
  return sum([10 ** i for i in rest])

def shortest(fr, rest, edges, dp):
  if rest == set():
    return 0
  if my_hash(rest) in dp[fr]:
    return dp[fr][my_hash(rest)]
  ret = INF
  for d, to in edges[fr]:
    if to in rest:
      score = d + shortest(to, rest - {to}, edges, dp)
      if score < ret:
        ret = score
  dp[fr][my_hash(rest)] = ret
  return ret

def main():
  while True:
    w, h = map(int, input().split())
    if w == 0:
      break
    mp = ["x" + input() + "x" for _ in range(h)]
    mp.insert(0, "x" * (w + 2))
    mp.append("x" * (w + 2))
    
    stains = []
    for y in range(1, h + 1):
      for x in range(1, w + 1):
        if mp[y][x] == "*":
          stains.append((x, y))
        elif mp[y][x] == "o":
          start = len(stains)
          stains.append((x, y))
    
    stain_num = len(stains)
    edges = [[] for _ in range(stain_num)]
    D = [[None] * stain_num for _ in range(stain_num)]
    for i in range(stain_num):
      D[i][i] = 0
    miss_flag = False
    for i in range(stain_num):
      for j in range(i + 1, stain_num):
        fr = stains[i]
        to = stains[j]
        d = dist(fr, to, mp)
        if d == -1:
          miss_flag = True
        edges[i].append((d, j))
        edges[j].append((d, i))
        D[i][j] = d
        D[j][i] = d
    if miss_flag:
      print(-1)
      continue


    dp = [{} for _ in range(10)]
    print(shortest(start, {i for i in range(stain_num) if i != start}, edges, dp))
main()


Measured memory_bytes: 5908
N = int(input())
S = input().strip()
A = [0 for _ in range(N+1)]
for i in range(N):
    if S[i]=="(":
        A[i+1] = A[i]+1
    else:
        A[i+1] = A[i]-1
amin = min(A)
a = A[-1]
if amin>=0:
    x = S+")"*a
else:
    x = "("*abs(amin)+S
    a += abs(amin)
    x = x+")"*a
print(x)

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

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a >= 13) {
		cout << b << endl;
		return 0;
	}
	else if (a >= 6 && a <= 12) {
		cout << b / 2 << endl;
		return 0;
	}
	else {
		cout << 0 << endl;
		return 0;
	}
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            var countlist = new List<int>();

            while (true)
            {
                var str = Console.ReadLine();

                if (str == "0 0")
                {
                    break;
                }

                var strer = str.Split(' ');

                int n = int.Parse(strer[0]);
                int x = int.Parse(strer[1]);
                int count = 0;

                for (int i = 1; i <= n; i++)
                {
                    for (int j = i + 1; j <= n; j++)
                    {
                        for (int k = j + 1; k <= n; k++)
                        {
                            if (i + j + k == x)
                            {
                                count++;
                            }
                        }

                    }
                }

                countlist.Add(count);

            }

            foreach (int v in countlist)
            {
                Console.WriteLine(v);
            }
            
        }
    }
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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 = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  int ans=INF;
  for(int i = 0; i < (s.size()-t.size()+1) ; i++){
    int cnt=0;
    for(int j = 0; j < t.size(); j++){
      if(t[j]!=s[j+i])cnt++;
    }
    chmin(ans,cnt);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3624