akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d1[100100];
ll d2[100100];
ll d3[100100];
ll d4[100100];
ll d5[100100];
ll d6[100100];

int main() {
	ll n,c;
	cin>>n>>c;
	vector<ll> vx;
	vector<ll> vv;
	rep(i,0,n){
		ll a,b;
		cin>>a>>b;
		vx.pb(a);
		vv.pb(b);
	}
	ll mx = 0;
	ll a = 0;
	rep(i,0,vx.sz){
		a += vv[i];
		d1[i] = a-vx[i];
		mx = max(mx,d1[i]);
	}
	ll b = 0;
	per(i,0,vx.sz){
		b += vv[i];
		d2[i] = b - (c-vx[i]);
		mx = max(mx,d2[i]);
	}
	rep(i,0,vx.sz){
		d3[i] = max(0LL,d1[i]-vx[i]);
		if(i>0){
			if(d3[i]<d3[i-1]){
				d3[i] = d3[i-1];
			}
		}
	}
	per(i,0,vx.sz){
		d4[i] = max(0LL,d2[i]-(c-vx[i]));
		if(i<vx.sz-1){
			if(d4[i]<d4[i+1]){
				d4[i] = d4[i+1];
			}
		}
	}
	rep(i,0,vx.sz){
		d5[i] = max(0LL,d1[i]);
		if(i>0){
			if(d5[i]<d5[i-1]){
				d5[i] = d5[i-1];
			}
		}
	}
	per(i,0,vx.sz){
		d6[i] = max(0LL,d2[i]);
		if(i<vx.sz-1){
			if(d6[i]<d6[i+1]){
				d6[i] = d6[i+1];
			}
		}
	}
	rep(i,0,vx.sz-1){
		mx = max(mx,d3[i]+d6[i+1]);
	}
	rep(i,1,vx.sz){
		mx = max(mx,d4[i]+d5[i-1]);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 6764
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var d string
	fmt.Scan(&d)
	X, _ := strconv.Atoi(d)
	if X == 7 || X == 5 || X == 3 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const int MAXN=2000001;
ll lsum[MAXN],rsum[MAXN],arr[MAXN];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    multiset<ll> L,R;
    int n; cin>>n;
    for(int i=1;i<=3*n;i++)
        cin>>arr[i];
    long long mx=0;
    long long mn=0;
    for(int i=1;i<=3*n;i++){
        L.insert(arr[i]);
        mx+=arr[i];
        if(L.size()>n){
            mx-=*L.begin();
            L.erase(L.begin());
        }
        lsum[i]=mx;
    }
    for(int i=3*n;i>=1;i--){
        R.insert(arr[i]);
        mn+=arr[i];
        if(R.size()>n){
            mn-=*(--R.end());
            R.erase((--R.end()));
        }
        rsum[i]=mn;
    }
    long long ans=-1e18;
    for(int i=n;i<=2*n;i++){
        ans=max(ans,lsum[i]-rsum[i+1]);
    }
    cout<<ans;
    return 0;
}


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

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

#define MOD 1000000007LL

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

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

int main(void) {
    string S;
    cin >> S;
    if(S.back() == 's') S += "es";
    else S.push_back('s');
    cout << S << endl;
    return 0;
}


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

int main(){
  int r, c, n;
  cin >> r >> c >> n;
  vector<bool> u(n,true);
  vector<P> v;
  rep(i,n) {
    int x[2], y[2];
    rep(j,2) {
      cin >> x[j] >> y[j];
      if(x[j] != 0 and x[j] != r and y[j] != 0 and y[j] != c) u[i] = false;
    }
    if(u[i]) {
      rep(j,2) {
        if(y[j] == 0) v.push_back(P(x[j],i));
        else if(x[j] == r) v.push_back(P(r+y[j],i));
        else if(y[j] == c) v.push_back(P(c+2*r-x[j],i));
        else v.push_back(P(2*c+2*r-y[j],i));
      }
    }
  }
  sort(v.begin(),v.end());
  stack<int> st;
  vector<bool> f(n,false);
  bool can = true;
  for(P p : v) {
    if(!f[p.second]) {
      st.push(p.second);
      f[p.second] = true;
    } else {
      if(st.top() != p.second) {
        can = false;
        break;
      } else st.pop();
    }
  }
  cout << (can? "YES" : "NO") << endl;
  return 0;
}

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

#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define lim 100010
#define mod 1e9 + 7
#define INF 1e9
#define REP(i, n) for (int i = 0; i < n; i++)

ll GCD(int x, int y) { return x % y == 0 ? y : GCD(y, x % y); }

int main() {
  int N;
  scanf("%d", &N);
  string S;
  map<string, int> memo;
  REP(i, N) {
    cin >> S;
    memo[S] += 1;
  }
  //最大出現回数を計算
  int c = 0;
  for (const auto& x : memo) {
    int v = x.second;
    c = c > v ? c : v;
  }

  // map内で辞書順になっているので、最大出現回数のものを出力
  for (auto it = memo.begin(); it != memo.end(); it++) {
    if (it->second == c) {  // itはmapの要素のアドレス
      cout << it->first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }
typedef pair<ll, ll> P;

vector<P> G[100100];

vector<ll> d(100100, INF);

void dijkstra() {
  d[0] = 0;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push({0, 0});
  while (!pq.empty()) {
    ll dist = pq.top().first, v = pq.top().second;
    pq.pop();
    if (d[v] < dist) continue;
    for (auto e: G[v]) {
      ll c = e.first, u = e.second;
      if (chmin(d[u], d[v] + c)) {
        pq.push({d[u], u});
      }
    }
  }
}

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

  ll n, m;
  cin >> n >> m;
  rep(i, n - 1) G[i + 1].push_back({0, i});
  rep(i, m) {
    ll l, r, c;
    cin >> l >> r >> c;
    l--, r--;
    G[l].push_back({c, r});
  }

  dijkstra();
  cout << (d[n - 1] == INF ? -1 : d[n - 1]) << '\n';





  
  return 0;
}

Measured memory_bytes: 10232
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main() {
	int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
	vector<long long> p(a), q(b), t(c);
	for (auto& e : p) cin >> e;
	for (auto& e : q) cin >> e;
	for (auto& e : t) cin >> e;
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	for (int i = 0; i < x; ++i) t.push_back(p[i]);
	for (int i = 0; i < y; ++i) t.push_back(q[i]);
	sort(t.rbegin(), t.rend());
	cout << accumulate(t.begin(), t.begin() + x + y, 0LL) << endl;

	return 0;
}

Measured memory_bytes: 6512
require 'complex'

N, D = gets.split.map(&:to_i)
array = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
count = 0
array.each do |p, q|
  if Math.sqrt(p ** 2 + q ** 2) <= D
    count += 1
  end
end

puts count


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

using namespace std;

const int INF = (1 << 30) - 1;

int main()
{
    string s;
    cin >> s;
    const int n = s.length();

    map<char, bool> f;

    vector<long long> mask(n);

    for (int i = 0; i < n; ++i) {
        f[s[i]] ^= 1;

        long long &now = mask[i];
        for (int j = 'a'; j <= 'z'; ++j) {
            now += (1 << (j - 'a')) * f[j];
        }
    }

    vector<int> DP(n, INF);

    map<long long, int> best_for_mask;

    auto update_for_i = [&] (int i)
    {
        if (!best_for_mask.count(mask[i]) ||
                best_for_mask[mask[i]] > DP[i]) {
            best_for_mask[mask[i]] = DP[i];
        }
    };
    best_for_mask[0] = 0;

    for (int i = 0; i < n; ++i) {

        int best = INF;
        auto check_cand = [&] (long long cand)
        {
            auto it = best_for_mask.find(cand);
            if (it == best_for_mask.end()) {
                return;
            }
            int now = it->second;
            if (now < best) {
                best = now;
            }
        };

        check_cand(mask[i]);
        for (int j = 'a'; j <= 'z'; ++j) {
            long long cand = mask[i] ^ (1 << (j - 'a'));
            check_cand(cand);
        }

        if (best == INF) {
            continue;
        }

        DP[i] = 1 + best;
        update_for_i(i);
    }

    cout << DP[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 15236
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;

int main() {
    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, m;
    cin >> n >> m;
    int start = INT_MIN, end = INT_MAX;
    int l, r;
    while (m--) {
        cin >> l >> r;
        start = max(start, l);
        end = min(end, r);
    }

    cout << max(0, end - start + 1);
}



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


auto solve(long long N, long long T, std::vector<long long> t){
    long long acc = 0;
    for(int i = 0; i < (N-1); ++i) {
        acc += min(T, t[i+1] - t[i]);
    }
    acc += T;

    return acc;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&t[i]);
    }
    auto result = solve(N, T, std::move(t));
    cout << result << endl;;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

void test_case(){
    
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>> n;
    cout<<(n+1)/2<<endl;
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int x;cin >> x;
	int ret = 0;
	ret += x/11*2;
	x %= 11;
	if(x && x <= 6){
		ret++;
	}
	else if(x){
		ret += 2;
	}
	
	
	

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

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1, j = (N-1); i < j; ++i, --j) {
        if (i + j == N) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.array;
import std.conv;
import std.string;

void main() {
  string[] input = split(readln());
  int a = to!int(input[0]);
  int b = to!int(input[1]);

  writeln(to!string(a * b) ~ " " ~ to!string(2 * (a + b)));
}

Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
using namespace std;
int n,k;
int ans;
int main()
{
	scanf("%d%d",&n,&k);
	ans=k;
	for(int i=1;i<n;i++)ans*=(k-1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

constexpr int MAX_N = 100000;
int N;
int A[MAX_N];

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

void _main() {
  cin >> N;
  rep(i, 0, N) cin >> A[i];

  int ans = A[0];
  rep(i, 1, N) {
    ans = gcd(ans, A[i]);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 640
def ED(a,b):
  x=list(a)
  y=list(b)
  m=len(x)
  n=len(y)
  A=[[0 for i in range(m+1)]for j in range(n+1)]
  for i in range(m+1):
    A[0][i]=i
  for i in range(n+1):
    A[i][0]=i
  
  for i in range(1,n+1):
    for j in range(1,m+1):
      if x[j-1]==y[i-1]:
        cnt=A[i-1][j-1]
      else:
        cnt=A[i-1][j-1]+1
      A[i][j]=min(A[i-1][j]+1,A[i][j-1]+1,cnt)
  return A[n][m]
  

a=input()
b=input()
print(ED(a,b))


Measured memory_bytes: 43496
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
    int u,minv,i,v;
    int d[MAX],p[MAX],color[MAX];

    for(i=0;i<n;i++){
        d[i] = INFTY;
        p[i] =  -1;
        color[i] = WHITE;
    }
    
    d[0] = 0;

    while(1){
        minv = INFTY;
        u = -1;
        for(i=0;i<n;i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(v=0;v<n;v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for(i=0;i<n;i++){
        if(p[i] != -1) sum += M[i][p[i]];
    }

    return sum;
}

int main(){
    int i,j,e;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&e);
            if(e == -1) M[i][j] = INFTY;
            else M[i][j]  = e;
        }
    }
    printf("%d\n",prim());

    return 0;
}


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

int n,ans;
int a[300100],b[300100];
char s[300100];

int main()
{
	scanf("%d",&n);
	ans=n*5;
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)
	{
		a[i]=a[i-1];
		if (s[i]=='W') a[i]++;
	}
	for (int i=n;i;i--)
	{
		b[i]=b[i+1];
		if (s[i]=='E') b[i]++;
	}
	for (int i=1;i<=n;i++) ans=min(ans,a[i-1]+b[i+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int h,w;
	cin >> h >> w;
	rep(i,0,h){
		rep(j,0,w){
			string s;
			cin >> s;
			if(s == "snuke")
				cout << char('A'+j) << i+1 << endl;
		}
	}
	ret 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int a[3][3] = {0};

    rep(i, 3)rep(j, 3) cin >> a[i][j];

    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) {
        cin >> b[i];
    }
    bool bin[3][3] = {0};
    rep(k, n){
        rep(i, 3)rep(j, 3){
            if (b[k] == a[i][j]) bin[i][j] = true;
        }
    }

    // rep(i, 3){
    //     rep(j, 3) cout << bin[i][j];
    //     cout << endl;
    // }
    bool ans = false;
    rep(i, 3){
        if (bin[i][0] && bin[i][1] && bin[i][2]) ans = true; 
    }
    rep(i, 3){
        if (bin[0][i] && bin[1][i] && bin[2][i]) ans = true;
    }
    if(bin[0][0] && bin[1][1] && bin[2][2]) ans =true;
    if(bin[2][0] && bin[1][1] && bin[0][2]) ans =true;

    if(ans)  puts("Yes");
    else puts("No");

}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>

using namespace std;



int main(void)
{
    long int A,B,C,D;
    cin>>A>>B>>C>>D;
    
    long int p=C;
    long int q=D;
    
    if(C>D){
        p=C;
        q=D;
    }
    else{
        p=D;
        q=C;
    }
    
    long int r=p%q;
    while(r!=0){
        p=q;
        q=r;
        r=p%q;
    }
    

    
    long int x=B-(B/C+B/D-B/(C*D/q));
    long int y=(A-1)-((A-1)/C+(A-1)/D-(A-1)/(C*D/q));
    
    cout<<x-y<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sp <<" "<<
bool isprime(ll n){
    if (n <= 1)return false;ll g=sqrt(n);
    for (ll i = 2; i <= g; i++)if (n % i == 0)return false;
    return true;
}
ll MOD=LLONG_MAX;
ll power(ll base, ll exp)
{
    if(exp==1)return base;
    else{if(exp%2==0){ll base1=(pow(power(base, exp/2),2));return base1%MOD;}
        else{ll ans=(base*pow(power(base,(exp-1)/2),2));return ans%MOD;}}
}
ll temp,temp1,temp2;
int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string in;
    cin>>in;
    int res=0,c=0;
    for(int i=0;i<3;i++)
    {
        if(in[i]=='R')
            c++;
        else
        {
            res=max(res,c);
            c=0;
        }
        //cout<<c<<endl; 
    }
    res=max(res,c);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void f( char *p )
{
    int i=0,q=0,h,huan;
    while(p[i]!='\0')
        i++;
    h=i-1;
    while(q<=h)
    {
        huan=p[q];
        p[q]=p[h];
        p[h]=huan;
        q++;
        h--;
    }
    return ;
}
int main()
{
	char s[200],s1[200],a[200],s2[200],b[200];
	
	while(scanf("%s %s",s,s1)!=EOF)
	//printf("%s %s",s,s1);
	{
	strcpy(s2,s);
	int len=strlen(s),flag=0,h=0;
 if(strcmp(s,s1)==0)flag=1;
	for(int i=len-1,h=0;i>0;i--,h++)
	{ memset(b,0,sizeof(b));
		a[h]=s[i];

		a[h+1]='\0';
		s2[i]='\0';
		strcpy(b,a);
		 f(b);
		strcat(b,s2);
		//strcpy(b,a);
		//strcpy(s2,b);
		//printf("%s\n",b);
	//strcat(b,s2);
	//	printf("%s\n",b);
		if(strcmp(b,s1)==0)
		{
		flag=1;
		break;	
		}
	}
	if(flag==1)printf("Yes\n");else printf("No\n");
	memset(s,0,sizeof(s));
	memset(s1,0,sizeof(s1));
	memset(s2,0,sizeof(s2));
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
}
}

Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std ;
using ll = long long ;
int main(){
	int n,m ;
	cin >> n >> m ;
	vector<pair<ll,ll>> shop(n) ;
	for(int i=0;i<n;i++) cin >> shop.at(i).first >> shop.at(i).second ;
	sort(shop.begin(),shop.end()) ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		if(m<=shop.at(i).second){
			ans += shop.at(i).first*m ;
			break ;
		}else{
			ans += shop.at(i).first*shop.at(i).second ;
			m -= shop.at(i).second ;
		}
	}
	cout << ans << endl ;
}

Measured memory_bytes: 1792
#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++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  string s,t;
  cin >> s >> t;
  
  int ans=0;
  rep(i,3){
    if(s[i]==t[i]) ans++;
  }
  
  cout << ans;
  
  return 0;
}

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

class Main
{

	private static boolean exhaustiveSearch(int[] a, int currentIndex, int target, int sum) {

		if (sum == target)
			return true;

		if (currentIndex >= a.length) 
			return false;

		return exhaustiveSearch(a, currentIndex + 1, target, sum) || exhaustiveSearch(a, currentIndex + 1, target, sum + a[currentIndex]);

	}

	public static void main(String[] args) {
		try(Scanner reader = new Scanner(new InputStreamReader(System.in)))
		{
			int n = reader.nextInt();
			reader.nextLine();
			int[] a = new int[n];

			for (int i = 0; i < a.length; i++) {
				a[i] = reader.nextInt();
			}
			reader.nextLine();
			
			int q = reader.nextInt();

			for (int i = 0; i < q; i++) {
				System.out.println(Main.exhaustiveSearch(a, 0, reader.nextInt(), 0) ? "yes" : "no");
			}


		}catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 26824
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int N;
    cin >> N;
    int a[3] = {0, 0, 0};
    ll ans = 1;
    REP(i, N){
        int x, cnt = 0;
        cin >> x;
        bool flag = true;
        REP(j, 3){
            if(a[j] == x){
                if(flag) a[j]++, flag = false;
                cnt++;
            }
        }
        ans = (ans * cnt) % MOD;
    }
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, T;
  cin >> N >> T;
  vector<int>cost(N);
  vector<int>time(N);
  for (int i = 0; i < N; i ++) {
    cin >> cost[i] >> time[i] ;
    if (time[i] > T) cost[i] = 2000;
  }
  sort (cost. begin(), cost.end());
  if (cost[0] > 1000) cout << "TLE" << endl;
  else cout << cost[0] << endl;
}
  


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

typedef long long ll;
ll n, s, t, mx = -1, x, x2, a[55];
int main()
{
	ll i, j, k;
	cin >> n;
	mx = -1;
	for (i =0; i < n; i++) {
		scanf ("%lld", &a[i]);
		if (a[i] > mx) {
			mx = a[i];
			x = i;
		}
	}
	while (1) {
		t = (a[x] - n + 1) / n;
		if ((a[x] - n + 1) % n) t++;
		s += t;
		mx = -1;
		for (i = 0; i < n; i++) {
			if (i == x) a[i] -= t * n;
			else a[i] += t;
			if (a[i] > mx) {
				mx = a[i];
				x2 = i;
			}
		}
		x = x2;
		if (mx < n) break;
	}
	cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll ans = 0; 
    rep1(i, n){
        if (s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3920
# -*- coding:utf-8 -*-
# https://atcoder.jp/contests/abc128/tasks/abc128_c

def solve():
    N, M = list(map(int, input().split()))
    denkyu = []
    for i in range(M):
        inputs = list(map(int, input().split()))
        k, Ss = inputs[0], inputs[1:]
        denkyu.append(Ss)
    Ps = list(map(int, input().split()))

    # スイッチの状態をbit全探索
    ans = 0
    for bits in range(2**N): # 1024
        light = 0  # 点灯している数
        for j in range(M): # 10
            total = 0
            for sw in denkyu[j]: # 10
                if (bits>>(sw-1)&1):
                    total += 1
            if total%2 == Ps[j]:
                light += 1
            else:
                break
        if light == M:
            ans += 1
    print(ans)


if __name__ == "__main__":
    solve()


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


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

int main(){
  int A,B;cin>>A>>B;
  int min=0;
  for(int i=0;i<10000;i++){
    if(A==int(i*1.08)-i&&B==int(i*1.1)-i){
      min=i;
      break;
    }
  }
  if(min){
    cout<<min<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}

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

int main() {
  int n, m, s = 0;
  cin >> n >> m;
  vector<vector<int>> v(m);
  vector<int> p(m);
  rep(i, m){
    int k;
    cin >> k;
    rep(j, k){
      int r;
      cin >> r;
      v[i].push_back(r-1);
    }
  }
  rep(i, m) cin >> p[i];
  rep(i, 1 << n){
    bool b = 1;
    rep(j, m){
      int a = 0;
      rep(l, v[j].size()) if(i & 1 << v[j][l]) ++a;
      if(a % 2 != p[j]) b = 0;
    }
    if(b) ++s;
  }
  cout << s << endl;
  return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	
	int n,sum=0,ave;
	int a[100];
	int ans[2]={0};
	cin>>n;
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	
	ave=sum/n;
	for(int i=0;i<n;i++)
		ans[0]+=(a[i]-ave)*(a[i]-ave);
	for(int i=0;i<n;i++)
		ans[1]+=(a[i]-(ave+1))*(a[i]-(ave+1));
	
	sort(ans,ans+2);
	cout<<ans[0]<<endl; 
	return 0;
}

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

int main(){
    vector<int> v(5,0);
    for(auto&& x:v)cin>>x;
    sort(v.begin(),v.end());
    //for(auto&& x:v)x=((x-1)/10+1)*10;
    int a=0;for(int i=0;i<5;i++ )a+=((v[i]-1)/10+1)*10;
    int b=10;
    for(int i=0;i<5;i++)
    {
        int c=v[i]%10;
   //     for(int i=0;i<5;i++)cout<<v[i];
      if(c>0)  b=min(b,c);
   //   cout<<b<<" "<<c<<" ";
    }
    
    cout <<a+b-10<<endl;

}

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

struct DataBox
{
	int frequentCount;
	int maxLength;
	string frequentWord;
	string maxLengthWord;

	DataBox() : frequentCount(0), maxLength(0)	/* constructer */
	{
	}
};

int main(void)
{
	struct DataBox dataBox;
	string sentence;
	int count = 0;

	int maxSentenceWord = 1000;
	int maxWord = 32;
	int sentenceWordCount = 0;
	int wordCount = 0;
	string wordBox[1000];

	while(cin >> sentence)	/* input */
	{
		sentenceWordCount++;
		
		/* check */
		wordCount = (int)sentence.size();
		if(dataBox.maxLength < wordCount)
		{
			dataBox.maxLength = wordCount;
			dataBox.maxLengthWord = sentence;
		}

		wordBox[count] = sentence;
		count++;
	}

	/* check */
	int freCount = 0;
	for(int boxNum = 0; boxNum < count; boxNum++)
	{
		string str = wordBox[boxNum];
		for(int word = 0; word < count; word++)
		{
			if(str == wordBox[word])
			{
			    freCount++;
			}
			
			if(dataBox.frequentCount < freCount)
			{
				dataBox.frequentCount = freCount;
				dataBox.frequentWord = str;
			}  
		}
		freCount = 0;
	}

	cout << dataBox.frequentWord << ' ' << dataBox.maxLengthWord << endl;
	return 0;
}

Measured memory_bytes: 3164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class AConnectionAndDisconnection {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();
            int k = in.nextInt();

            long ans = 0;
            List<Integer> runs = new ArrayList<>();
            for (int i = 0; i < s.length(); ) {
                int j = i;
                while (j < s.length() && s.charAt(i) == s.charAt(j)) {
                    j++;
                }
                runs.add(j - i);
                i = j;
            }
            for (int i : runs) {
                ans += (long) k * (i / 2);
            }
            if (s.charAt(0) == s.charAt(s.length() - 1)) {
                if (runs.size() == 1) {
                    ans = (long) k * s.length() / 2;
                } else {
                    ans -= (long) (k - 1) * (runs.get(0) / 2);
                    ans -= (long) (k - 1) * (runs.get(runs.size() - 1) / 2);
                    ans += (long) (k - 1) * ((runs.get(0) + runs.get(runs.size() - 1)) / 2);
                }
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 23380
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    int n, m; cin >> n >> m;
    double sum = 0;
    vector<double> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double q = 1.0/(4.0*(double)m);
    int c = 0;
    for(int i=0; i<n; i++) {
        if(a[i]>=sum*q) c++;
    }
    if(c>=m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
 
using namespace std;
 
bool f[100001];
int c[100001];
int main(){
  int i,j;
  for(i=2;i<=100000;i++)if(!f[i])for(j=i+i;j<=100000;j+=i)f[j]=1;
  for(i=3;i<=100000;i+=2)if(!f[i]&&!f[(i+1)/2])c[i]++;
  for(i=3;i<=100000;i++)c[i]+=c[i-1];
  int q;
  cin >> q;
  for(i=0;i<q;i++){
    int l,r;
    cin >> l >> r;
    cout << c[r]-c[l-1] << endl;
  }
  return 0;
}

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

int main() {
  	int N;
	string S;
	string mes;
  
	int i;
	i = 0;
	cin >> N;
 
while (i <= N){
	cin >> S;
	if ( S == "Y" ){
		mes = "Four";
		break;
	}else{
		mes = "Three";
	}
  i++;
}
  	cout << mes;
}


Measured memory_bytes: 3608
import bisect
import statistics
n = int(input())
a = list((int(x) for x in input().split()))

a.sort()
incl = []
score = 0

for i in range(len(a)):
    ain = a.pop()
    incl.append(ain)
    if i==0: continue
    if (len(incl)%2 == 1):
        score += incl[ int(len(incl)/2) ]
    else:
        # smaller of middle two
        score += incl[ int(len(incl)/2)-1 ]

print(score)

Measured memory_bytes: 33836
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
typedef pair<int,int> Pp;


signed main(){
    int N,M;
    int P[114514],Y[114514];
    vector<int> city[114514];
    map<int,int> G[114514];
    
    cin >> N >> M;
    REP(i,M){
        cin >> P[i] >> Y[i];
        city[P[i]].push_back(Y[i]);
    }
    
    int y[114514],now=0;
    OREP(j,N){
        now=0;
        REP(i,city[j].size()){
            y[i]=city[j][i];
        }
        sort(y,y+city[j].size());
        REP(i,city[j].size()){
            if(i!=0 && y[i]!=y[i-1]){
                now++;
            }
            G[j][y[i]]=now;
        }
    }
    
    REP(i,M){
        printf("%06lld",P[i]);
        printf("%06lld\n",G[P[i]][Y[i]]+1);
    }
    
    return 0;
}   


Measured memory_bytes: 21120
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
const int MAX = 111;

struct vec {
    int x, y;
    vec() {}
    vec(int a, int b)
    {
        x = a, y = b;
    }
    bool operator>(const vec a) const
    {
        return x == a.x ? y > a.y : x > a.x;
    }
    vec operator-(const vec a) const
    {
        return vec(x - a.x, y - a.y);
    }
    vec operator+(const vec a) const
    {
        return vec(x + a.x, y + a.y);
    }
} p[MAX];
int n;
double chaji(vec a, vec b, vec c)
{
    vec A = vec(b - a), B = vec(c - a);
    return A.x * B.y - A.y * B.x;
}
bool duobianxingnei(vec& t)
{
    int t1, t2, f, sum, i;
    for (i = 0; i <= n; i++)
        p[i].x -= t.x, p[i].y -= t.y; // 坐标平移
    t1 = p[0].x >= 0 ? (p[0].y >= 0 ? 0 : 3) : (p[0].y >= 0 ? 1 : 2); // 计算象限
    for (sum = 0, i = 1; i <= n; i++) {
        if (!p[i].x && !p[i].y)
            break;
        // 被测点为多边形顶点
        f = p[i].y * p[i - 1].x - p[i].x * p[i - 1].y;

        // 计算叉积
        if (!f && p[i - 1].x * p[i].x <= 0 && p[i - 1].y * p[i].y <= 0)
            break; // 点在边上
        t2 = p[i].x >= 0 ? (p[i].y >= 0 ? 0 : 3) : (p[i].y >= 0 ? 1 : 2); // 计算象限
        if (t2 == (t1 + 1) % 4)
            sum += 1;
        // 情况1
        else if (t2 == (t1 + 3) % 4)
            sum -= 1;
        // 情况2
        else if (t2 == (t1 + 2) % 4)
        // 情况3
        {
            if (f > 0)
                sum += 2;
            else
                sum -= 2;
        }
        t1 = t2;
    }
    bool tf = 0;
    if (i <= n || sum)
        tf = 1;
    for (i = 0; i <= n; i++)
        p[i].x += t.x, p[i].y += t.y; // 恢复坐标
    return tf;
}

bool dian_zai_xianshang(vec a, vec b, vec c)
{
    int x1 = a.x, x2 = b.x, y1 = a.y, y2 = b.y;
    if (x1 > x2)
        swap(x1, x2);
    if (y1 > y2)
        swap(y1, y2);
    if (chaji(a, b, c) == 0 &&x1<=c.x&&c.x<=x2&&y1<=c.y&&c.y<=y2)
        return 1;
    return 0;
}
bool zaibianshang(vec& t)
{
    for (int i = 0; i < n; i++)
        if (dian_zai_xianshang(p[i], p[(i + 1) % n], t))
            return 1;
    return 0;
}
int main()
{
    //freopen("txt.txt", "w", stdout);
    int m;
    vec t;
    cin >> n;
    for (int i = 0; i < n; i++)
        scanf("%d%d", &p[i].x, &p[i].y);
    p[n] = p[0];

    scanf("%d", &m);
    while (m--) {
        bool tf = false;
        scanf("%d%d", &t.x, &t.y);
        if (zaibianshang(t))
            cout << 1 << endl;
        else if (duobianxingnei(t))
            cout << 2 << endl;
        else
            cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 3240
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n=0;
        outer:while(true)
        {
            n=sc.nextInt();
            if(n>100)
            continue;
            else
            break outer;
        }
        int i=0;
        while((int)(Math.pow(2,i))<=n)
        {
            i++;
        }
        i--;
        System.out.println((int)(Math.pow(2,i)));
    }
}

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

int main(){
int n;
cin>>n;
int a[4];
for(int i=0;i<4;i++){
a[i]=n%10;
n/=10;
}
for(int i=0;i<3;i+=2){
  for(int j=0;j<3;j+=2){
    for(int k=0;k<3;k+=2){
      int S=a[3];
      if(k==0){
        S+=a[2];
      }
      else if(k==2){
        S-=a[2];
      }  if(j==0){
        S+=a[1];
      }
      else if(j==2){
        S-=a[1];
      }  if(i==0){
        S+=a[0];
      }
      else if(i==2){
        S-=a[0];
      } 
      if(S==7){
        char A='+'+k,B='+'+j,C='+'+i;
        cout<<a[3]<<A<<a[2]<<B<<a[1]<<C<<a[0]<<'='<<7<<endl;
        return 0;
      }
    }
  }
}


return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
int dfs(vector<int> adj[], int src, bool visited[], int dp[])
{
    visited[src] = true;

    for (auto child : adj[src])
    {
        if (!visited[child])
            dfs(adj, child, visited, dp);

        dp[src] = max(dp[src], 1 + (dp[child]));
    }

}
int findPath(vector<int> adj[], int n)
{
    int maxAns = -2;
    bool visited[n + 1] = {false};
    int dp[n + 1] ;
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
            dfs(adj, i, visited, dp);

    }
    return *max_element(dp, dp + n + 1);
    return maxAns;
}
void findAns()
{
    int n, m;
    cin >> n >> m;

    vector<int> adj[n + 1];

    int src, des;
    for (int i = 0; i < m; i++)
    {
        cin >> src >> des;
        adj[src].push_back(des);

    }

    cout << findPath(adj, n);

}
int main()
{


    FAST;

    // ll int t;
    // cin >> t;
    // while (t--)
    findAns();

    return 0;
}

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

int main(){

    while(true){
        int H, W;
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; ++i){
            for(int j = 0; j < W; ++j){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

int main(){
  int a,b,d=0;
  cin>>a>>b;
  vector<int> c(a);
  for(int i=0;i<a;i++)
    cin>>c.at(i);
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  for(int i=0;i<b;i++)
    d+=c.at(i);
  cout<<d<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
	ll q,h,s,d,n;
	cin>>q>>h>>s>>d>>n;
	q*=4;
	h*=2;
	ll t=min(min(q,h),s);
	if(d<q*2 && d<h*2 && d<s*2)
	{
		cout<<((n>>1)*d+(n&1)*t)<<endl;
	}
	else
	{
		cout<<n*t<<endl;
	}
}

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

int main(){
	double v;
	while( cin >> v ){
		double t, y;
		t = v / 9.8;
		y = 4.9 * t * t;
		int floar = (y + 5) / 5 + 1;
		cout << floar << endl;
	}
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;
using ll = long long;

void swap(pair<int, int>& a, pair<int, int>& b) {
	auto tmp = a;
	a = b;
	b = tmp;
}

void sort(vector<pair<int, int>>& arr, int l, int r) {
	if (r - l <= 1) return;

	int pivotIndex = r - 1;
	auto pivot = arr[pivotIndex];

	int i = l;
	for (int j = l; j < r - 1; ++j) {
		if (arr[j].second < pivot.second) {
			swap(arr[i], arr[j]);
			i++;
		}
	}
	swap(arr[i], arr[r - 1]);

	sort(arr, l, i);
	sort(arr, i + 1, r);
}


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

	vector<pair<int, int>> A(N);

	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		A[i] = make_pair(i + 1, a);
	}
	
	sort(A, 0, A.size());

	string ans = "";
	for (int i = 0; i < A.size(); ++i) {
		ans  += to_string(A[i].first);
		if (i != A.size() - 1) {
			ans += " ";
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int a[30];
int main()
{
string w;
cin>>w;
for(int i=0;i<w.size();i++)
{
      a[w[i]-97]++;


}
int flag=0;
for(int i=0;i<26;i++)
{
    if(a[i]%2!=0)
    {
        flag=1;
        break;
    }
}
if(flag==0)
    cout<<"Yes"<<endl;
else cout<<"No"<<endl;


}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll dp[111][111111];

int main(){
  int n,w;
   cin>>n>>w;
  vector<pair<ll,ll> > v(n+1);
   for(int i=1;i<=n;i++)cin>>v[i].first>>v[i].second;
   for(int i=1;i<=n;i++)for(int j=0;j<=w;j++){
     dp[i][j]=dp[i-1][j];
     if(j-v[i].first>=0)dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].first]+v[i].second);
   }
    ll ans=0;
    for(int i=0;i<=w;i++)ans=max(ans,dp[n][i]);
    cout<<ans;
}

Measured memory_bytes: 87296
S = input()
K = int(input())

if len(set(S)) == 1:
  print((len(S)*K)//2)
  exit()

dup = [1]
for i in range(1,len(S)):
  if S[i-1] == S[i]:
    dup[-1] += 1
  else:
    dup.append(1)
    
ans = 0
for i in dup:
  ans += (i//2)*K

if S[0] == S[-1]:
  ans += ((dup[0]+dup[-1])//2 - (dup[0]//2+dup[-1]//2))*(K-1)

print(ans)


Measured memory_bytes: 3064
n = int(input())

def dfs_stack(x): #xは探索対象の最大数n
    ans = 0
    stack = []
    stack.append(0)
    while stack:
        i = stack.pop()
        if i > n:
            continue
        ans += 1 if judge(i) else 0
        stack.append(int(str(i) + "3"))
        stack.append(int(str(i) + "5"))
        stack.append(int(str(i) + "7"))
    print(ans)
    
def judge(x:int) -> bool: #753数かを判定する
    if set(str(x)) == {"3", "5", "7"}:
        return True
    else:
        return False    

dfs_stack(n)

Measured memory_bytes: 3064