akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int long long
#define double long double

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll=long long;
using ld=double;

constexpr int MOD = 1e9+7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end(),greater<>());
    priority_queue<int> que;
    que.push(a[0]);
    int ans=0;
    rep(i,1,n){
        int it=que.top();que.pop();
        ans+=it;
        que.push(a[i]);
        que.push(a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}

int main(){
    ll n,d;cin>>n>>d;
    ll ans=0;
    while(n>0){
        n-=(2*d+1);
        ans ++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
    char s[200];
    int i,j,l;
    scanf("%s", s);
    l=strlen(s);

    if(s[0]!='A') {
        puts("WA");
        return 0;
    }

    int x=0;
    for(i=2;i<l-1;i++) {
        if(s[i]=='C') {
            x++;
            s[i]='c';
        }
    }

    if(x!=1) {
        puts("WA");
        return 0;
    }

    int flag=1;
    for(i=1;i<l;i++) {
        if('a'<=s[i] && s[i]<='z') {}
        else flag=0;
    }

    if(flag) puts("AC");
    else puts("WA");
}


Measured memory_bytes: 128
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a+b+c-d==7:
  print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif a+b-c+d==7:
  print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a-b+c+d==7:
  print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a+b-c-d==7:
  print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif a-b+c-d==7:
  print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a-b-c+d==7:
  print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif a-b-c-d==7:
  print('{}-{}-{}-{}=7'.format(a,b,c,d))

Measured memory_bytes: 3064
//بسم الله الرحمن الرحيم
//اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
//Allah in the name of The Most Affectionate, the Merciful
//अल्लाह के नाम से जो दयालु और कृपाशील है
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll 
#define pb push_back

#define endl '\n'
#define mod 1000000007

#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define MEMSET(t) memset(t,0,sizeof(t));
#define time clock_t tStart
#define Start clock()
#define Time printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC)



ll minC(int ar[], int n, ll dp[]) 
{
  if(n==1) return 0;
  if(dp[n]!=-1) return dp[n];
  if(n==2) return dp[n]=abs(ar[n-1]-ar[n-2]); 

  return dp[n]=min(
                    abs(ar[n-1]-ar[n-2])+minC(ar,n-1,dp),
                    abs(ar[n-1]-ar[n-3])+minC(ar,n-2,dp)  );    
  return 0;
}

int main()
{
  fastio; 
  int t=1;
  while(t--)
  {
    int n;
    cin>>n;

    int ar[n];
    ll dp[n+1];
    FOR(i,0,n) cin>>ar[i];

   memset(dp,-1,sizeof(dp));
    cout<< minC(ar,n,dp)<<endl;

  }
  return 0;
}   

Measured memory_bytes: 10576
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int a,b,k;
cin>>a>>b>>k;

int cnt=0;
pair<int,int> p[100];
for(int i=0;i<100;i++){
    p[i].first=0;
}

for(int i=min(a,b);i>=1;i--){
    if(a%i==0 && b%i==0){
        
        p[cnt].first=cnt;
        p[cnt].second=i;
        if(cnt==k-1){
            cout<<p[cnt].second<<endl;
            return 0;
        }
        cnt+=1;
        
    }
}





return 0;
}

Measured memory_bytes: 256
k, t = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
double_cnt = 0
total = 0
for i in range(t):
  b = a[i] - double_cnt
  c = total - (double_cnt + 1) + 2
  double_cnt = max(0, b-c)
  total += a[i]
print(double_cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

ll cal(ll y, ll x) {
  ll res = 1e18;
  rep(i, 1, y) {
    ll a = i * x;
    ll v = x / 2;
    ll b = v * (y - i);
    ll c = (x - v) * (y - i);
    chmin(res, max({a, b, c}) - min({a, b, c}));
  }
  return res;
}

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

  ll h, w;
  cin >> h >> w;

  ll hh = h / 3, ww = w / 3;
  ll a1 = h % 3 == 0 ? 0 : h;
  ll a2 = w % 3 == 0 ? 0 : w;

  ll ans = min({a1, a2, cal(h, w), cal(w, h)});
  cout << ans << endl;
}


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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,m,k[10],s[10][10],p[10],ans;

signed main() {
    cin >> n >> m;
    rep(i,m) {
        cin >> k[i];
        rep(j,k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i,m) cin >> p[i];
    int hoge = pow(2,n);
    rep(i,hoge) {
        int huga[10]={},z=0,ttmp = i;
        while(ttmp) {
            int tmp = ttmp%2;ttmp/=2;
            huga[z] = tmp;
            z++;
        }
        int ccnt=0;
        rep(j,m) {
            int cnt=0;
            rep(l,k[j]) {
                if (huga[s[j][l]]) cnt++;
            }
            if (cnt%2 == p[j]) ccnt++;
        }
        if (ccnt == m) ans++;

    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N;
// string S[210000];
set<string> res;
int main() {
    cin >> N;
    rep(i, N) {
        string s; cin >> s;
        res.insert(s);
    }
    cout << res.size() << endl;
    return 0;
}


Measured memory_bytes: 19148
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<in> a(n);rep(i,n)cin>>a[i]

int main(){
  int s,k,z;cin>>k>>s;
  int cnt=0;
  rep(x,k+1)rep(y,k+1){
    z=s-x-y;
    if(z>=0&&z<=k) cnt++;
  }
  cout<<cnt;
}


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

void pd(int a[18], int b[18], int c[18]) {
	for (int i = 0; i < 18; i++) {
		for (int j = 0; j < 18 - i; j++) {
			int u = i + j;
			int d = c[u] + a[i] * b[j];
			c[u] = d % 10000;
			while (u < 17 && d >= 10000) {
				d = c[u + 1] + d / 10000;
				c[u + 1] = d % 10000;
				u++;
			}
		}
	}
}

int main()
{
	int m, n;
	const int T = 10000;
	char a[17][4] = { "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou",
						"Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg",
						"Nyt", "Fks", "Mts" };

	cin >> m >> n;

	while (m != 0 || n != 0) {
		int b[8][18];

		memset(b, 0, sizeof(b));
		b[0][0] = m;

		for (int i = 0; i < 7; i++)
			pd(b[i], b[i], b[i + 1]);

		int c[18];
		memset(c, 0, sizeof(c));
		c[0] = 1;

		while (n > 0) {
			int i = 7;
			int d[18];
			memset(d, 0, sizeof(d));

			while (1 << i > n && i > 0)	
				i--;

			pd(c, b[i], d);

			for (int j = 0; j < 18; j++)
				c[j] = d[j];

			n -= 1 << i;
		}

		for (int i = 17; i >= 0; i--) {
			if (c[i] > 0) {
				cout << c[i];
				if (i > 0)
					cout << a[i - 1];
			}
		}
		cout << endl;

		cin >> m >> n;
	}

	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> Acnt(N + 1, 0);
  rep(i, N) {
    cin >> A[i];
    Acnt[A[i]]++;
  }
  vector<int> B(N);
  vector<int> Bcnt(N + 1, 0);
  rep(i, N) {
    cin >> B[i];
    Bcnt[B[i]]++;
  }
  rep(i, N + 1) {
    if (N < (Acnt[i] + Bcnt[i])) {
      cout << "No" << endl;
      return 0;
    }
  }

  int j = 0;
  int prev = -1;
  rep(i, N) {
    if (prev != A[i]) j = 0;
    if (A[i] == B[i]) {
      for (; j < N; ++j) {
        if (A[i] != A[j] && A[i] != B[j]) {
          swap(B[i], B[j]);
          break;
        }
      }
    }
    prev = A[i];
  }

  cout << "Yes" << endl;
  rep(i, N) {
    if (i != 0) cout << " ";
    cout << B[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U) cout << A - 1 << " " << B << endl;
    else cout << A << " " << B - 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui M{}, D{}; cin >> M >> D;

  if(D / 10 < 2)
  {
    cout << 0 << CRLF;
    return;
  }

  vector<ull> res(M);
  for(size_t month = 1; month <= M; ++month)
  {
    ull result{};
    for(ui day = 1; day <= D; ++day)
    {
      if(day / 10 < 2 || day % 10 < 2)
      {
        continue;
      }
      if((day / 10) * (day % 10) == month)
      {
        ++result;
      }
    }
    res[month - 1] = result;
  }

  auto ans = boost::accumulate(res, (ull)0);
  cout << ans << CRLF;

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;




void main() {
    int w, a, b;
    scan(w, a, b);
    auto ans = max(0, b - (a + w), a - (b + w));
    writeln(ans);
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=2500;
const long long INF=1e17;
int N,M,PF,vis[MAXN];
int Ok[MAXN],cnt[MAXN];
long long dist[MAXN],Ans;
vector<int>P[MAXN],T[MAXN],F[MAXN];
queue<int>Q;
void SPFA(int u,int val){
	for(int i=1;i<=N;i++)
		dist[i]=INF;
	while(!Q.empty())Q.pop();
	dist[u]=val;Q.push(u);cnt[u]++;
	while(!Q.empty()){
		u=Q.front();Q.pop();
		int size=P[u].size();
		for(int i=0;i<size;i++){
			int v=P[u][i];
			if(dist[v]>dist[u]+T[u][i]){
				dist[v]=dist[u]+T[u][i];
				if(cnt[v]>8*N+5){
					Ok[v]=1;
					continue;
				}
				cnt[v]++;
				Q.push(v);
			}
		}
	}
	if(dist[N]==INF)Ans=-1;
	else Ans=max(0*1LL,-dist[N]);
}
void FA(int u){
	int size=F[u].size();
	vis[u]=1;if(Ok[u])Ans=-1;
	for(int i=0;i<size;i++){
		int v=F[u][i];
		if(vis[v])continue;
		FA(v);
	}
}
int main(){
	scanf("%d%d%d",&N,&M,&PF);
	for(int i=1,x,y,z;i<=M;i++){
		scanf("%d%d%d",&x,&y,&z);
		P[x].push_back(y);
		F[y].push_back(x);
		T[x].push_back(PF-z);
	}
	SPFA(1,0);FA(N);
	printf("%lld\n",Ans);
}

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
   string s;
   cin >> s;
   int n = s.size();
   vector<int>cnt(26);
   rep(i, 0, n){
       cnt[s[i]-'a']++;
   }
   int cnt2=0;
   int ans = 100;
   rep(i, 0, 26){
       if(cnt[i]==0)continue;
       vector<int>v;
       char a = i +'a';
       rep(j, 0, n){
           if(s[j] == a){
               v.push_back(cnt2);
               cnt2=0;
           }else cnt2++;
       }
       if(cnt2>0)v.push_back(cnt2),cnt2=0;
       sort(v.begin(),v.end(),greater<int>());
       ans = min(ans,v[0]);
   }
   cout << ans << endl;
}

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

int n, k;
int imos[1000*4][1000*4];

int main() {

    // input
    cin >> n >> k;
    while(n--){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W') x += k;
        x %= 2*k;
        y %= 2*k;

        // +1, -1 for 2D-imos
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                int xx = x%k+i*k+1;
                int yy = y%k+j*k+1;
                if((xx+yy)%(2*k) != (x+1+y+1)%(2*k)) continue;
                if(xx+k < 4*k && yy+k < 4*k){
                    imos[xx][yy]++;
                    imos[xx+k][yy]--;
                    imos[xx][yy+k]--;
                    imos[xx+k][yy+k]++;
                }
            }
        }
    }

    // 2D-imos
    int ans = 0;
    for(int i=0;i<4*k;i++){
        for(int j=1;j<4*k;j++){
            imos[i][j] += imos[i][j-1];
        }
    }
    for(int i=1;i<4*k;i++){
        for(int j=0;j<4*k;j++){
            imos[i][j] += imos[i-1][j];
            ans = max(ans, imos[i][j]);
        }
    }

    // output
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool good = (s[a] == '-');
  for (int i = 0; i < a; ++i) if (s[i] == '-') good = false;
  for (int i = 0; i < b; ++i) if (s[a + i + 1] == '-') good = false;
  cout << (good ? "Yes" : "No") << endl;
}

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

int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> A(N), B(N);
    ll minv = 0;
    for (auto &e : A) { cin >> e; minv += e; }
    for (int i = 1; i < N; i++) {
        ll sum = 0;
        for (int j = 0; j < N; j++) B[(j+1)%N] = min(A[(j+1)%N], A[j]), sum += B[(j+1)%N];
        A = B;
        minv = min(minv, sum + i * X);
    }
    cout << minv << endl;
    return (0);
}


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

constexpr long long mod = 1000000007;

typedef pair<long long, long long> result; // true, false
#define T first
#define F second

struct parse_t {
	char c;
	result value;
	parse_t(char c_ = '#', const result &value_ = result()):c(c_), value(value_) {}
};

template<class T>
T take_back(vector<T> &vec) {
	assert(!vec.empty());
	const T res = vec.back();
	vec.pop_back();
	return res;
}

void push_value(vector<parse_t> &sta, const result &value) {
	if(!sta.empty() && sta.back().c == '~') {
		sta.pop_back();
		push_value(sta, result(value.F, value.T));
	}
	else {
		sta.emplace_back('v', value);
	}
}

result calculate_binary_operator(char ope, const result &a, const result &b) {
	switch(ope) {
	case '|': return result((a.T * (b.T + b.F) + a.F * b.T) % mod, a.F * b.F % mod);
	case '&': return result(a.T * b.T % mod, (a.F * (b.T + b.F) + a.T * b.F) % mod);
	default : assert(false);
	}
}

void evaluate_binary_operator(vector<parse_t> &sta) {
	const result b = take_back(sta).value;
	const char ope = take_back(sta).c;
	const result a = take_back(sta).value;
	push_value(sta, calculate_binary_operator(ope, a, b));
}

void print(const vector<parse_t> &sta) {
	return;
	cout << "stack = ";
	for(const auto &e : sta) cout << e.c;
	cout << endl;
}

result parse(const string &expression) {
	vector<parse_t> sta;
	sta.reserve(10000);

	int priority[256] = {};
	priority['|'] = 2;
	priority['&'] = 3;
	priority['('] = 100;
	priority[')'] = 1;

	print(sta);
	for(auto it = expression.cbegin(); it != expression.cend();) {
		//cout << "begin at " << it - expression.cbegin() << " c = " << *it << endl;
		if(*it == 'x') {
			++it; // x
			while(isdigit(*it)) ++it;
			push_value(sta, result(1, 1));
		}
		else if(*it == '~') {
			sta.emplace_back('~');
			++it;
		}
		else {
			while(sta.size() >= 3 && sta[sta.size() - 2].c != '('
				  && priority[sta[sta.size() - 2].c] >= priority[*it]) {
				evaluate_binary_operator(sta);
			}

			if(*it == ')') {
				assert(sta[sta.size() - 2].c == '(');
				const auto tmp = take_back(sta);
				assert(tmp.c == 'v');
				sta.pop_back(); // (
				push_value(sta, tmp.value);
			}
			else {
				sta.emplace_back(*it);
			}

			++it;
		}
		print(sta);
	}

	while(sta.size() >= 3) evaluate_binary_operator(sta);
	assert(sta.size() == 1);
	return sta.back().value;
}

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

	string expression;
	cin >> expression;
	cout << parse(expression).T << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 19436
n = int(input())
Total = []

for i in range(1, n + 1):

    if (i % 3 == 0) and (i % 5 == 0):
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        Total.append(i)

print(sum(Total))

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  vector<int> L(N);
  REP(i, N) L[i] = nextInt();
  sort(ALL(L));
  ll s = accumulate(ALL(L), 0LL);
  bool yes = s - L[N-1] > L[N-1];
  cout << (yes ? "Yes" : "No") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int> ans;
	for(int i = n; i >=0; ) {
		if(i <= m) {
			ans.push_back(i);
			break;
		}
		int now = -1;
		for(int j = m; j >=1; j--) {
			if(s[i-j] != '1') {
				ans.push_back(j);
				now = j;
				i -= j;
				break;
			}
		}
		if(now == -1) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	reverse(all(ans));
	rep(i, ans.size()) printf("%d%c", ans[i], (i==ans.size()-1) ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 1144
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#define REL
#endif
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

//#pragma GCC optimize("Ofast")
//#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

#define endl '\n'

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

mt19937 gen(34);
//mt19937_64 gen(41);


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("rps2.in", "r", stdin);
	//freopen("rps2.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//----------------------------------------------//
	int t = 1;
	//cin >> t;
	while (t--) {
		int a, b, c;
		cin >> a >> b >> c;
		swap(a, b);
		swap(a, c);
		cout << a << " " << b << " " << c;
	}
	//----------------------------------------------//

	return 0;
}




Measured memory_bytes: 256
M=1e9+7,D[101][64];j,T;main(i,n){for(D[0][63]=scanf("%d",&n);T=j<256?:(j=0,i++<n);j++)D[i][T=j%64]+=T-9&&T-33&&T-6&&j-25&&j-41&&j-57&&j-37&&j-45?D[i-1][j/4]:0,D[i][T]%=M;for(;j<64;T%=M)T+=D[n][j++];printf("%d",T);}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    long long n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;

    map<long long,long long> m1;
    map<long long,long long> m2;
    long long count=0;
    for(long long i=0;i<n;i++)
    {
        if(s[i]=='o')
        {
            count++;
            m1[i+1] = count;
            if(count==k)
                break;
            i+=c;
        }
    }
    count=0;
    for(long long i=n-1;i>=0;i--)
    {
        if(s[i]=='o')
        {
            count++;
            m2[i+1] = k+1-count;
            i-=c;
            if(count==k)
                break;
        }
    }
    for(auto i:m1)
    {
        long long t=i.first;
        if(i.second == m2[t])
        	cout<<i.first<<endl;
    }
    return 0;
}


Measured memory_bytes: 26772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++)
  {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  int ans = 1e9;
  for (int i = x[0]; i <= x[n - 1]; i++)
  {
    int buf = 0;
    for (int j = 0; j < n; j++)
    {
      buf += pow(x[j] - i, 2);
    }
    ans = min(ans, buf);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3604
n,k = map(int,input().split())

if n == k or k == 1:
    print(0)
    exit()

if n > k:
    temp = n%k
    if temp < abs(k-temp):
        ans = temp
    else:
        ans = abs(k-temp)
    print(ans)
else:
    if k-n < n:
        print(k-n)
    else:
        print(n)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  bool p[10001];
  memset(p, 1, sizeof(p));
  p[1] = p[0] = 0;
  for(int i = 0 ; i < 10001 ; i++){
    if(p[i]){
      for(int j = 2 * i ; j < 10001 ; j += i){
	p[j] = 0;
      }
    }
  }

  int n;
  while(cin >> n, n){
    for(int i = n ; ; i--){
      if(p[i] == 1 && p[i-2] == 1){
	cout << i-2 << ' ' << i << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s; cin >> s;
  ll k; cin >> k;

  ll a = 0;
  ll cnt = 0;
  rep(i,s.size()-1) {
    if (s[i]==s[i+1]) {
      if (cnt%2==0) {
        a++;
      }
      cnt++;
    }
    else {
      cnt = 0;
    }
  }

  if (s[0]!=s[s.size()-1]) {
    cout << (ll)k*a << endl;
    return 0;
  }

  bool same = true;
  rep(i,s.size()-1) {
    if (s[i]!=s[i+1]) {
      same = false;
      break;
    }
  }
  if (same && s.size()%2 != 0) {
    cout << (ll)k*a + k/2 << endl;
    return 0;
  }
  
  ll cnt_f = 1;
  rep(i,s.size()-1) {
    if (s[i]==s[i+1]) {
      cnt_f++;
    }
    else {
      break;
    }
  }

  reverse(rng(s));

  ll cnt_l = 1;
  rep(i,s.size()-1) {
    if (s[i]==s[i+1]) {
      cnt_l++;
    }
    else {
      break;
    }
  }

  ll ans;
  if (cnt_f%2==1 && cnt_l%2==1) {
    ans = (ll)k*a + k-1;
  }
  else {
    ans = (ll)k*a;
  }

  cout << ans << endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e15;

LL dp[2][3010];

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

  int N, T, S;
  cin >> N >> T >> S;
  VL xs(N), ys(N);
  REP(i,N) cin >> xs[i] >> ys[i];

  int crt = 0, nxt = 1;
  fill((LL*)dp, (LL*)dp+2*3010, -INF);
  dp[crt][0] = 0;
  REP(i,N){
	REP(t,T+1)
	  maxi(dp[nxt][t], dp[crt][t]);
	for(int t=0;t<=T;++t){
	  int nt = t + ys[i];
	  if(nt <= T && !(t < S && S < nt))
		maxi(dp[nxt][nt], dp[crt][t] + xs[i]);
	}
	FOR(t,1,T+1)
	  maxi(dp[nxt][t], dp[nxt][t-1]);
	swap(crt, nxt);
  }

  cout << *max_element(dp[crt], dp[crt]+T+1) << endl;

  return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int n, cnt[1000001], x_squared, y_squared, z_squared;

int main() {
    cin >> n;
    for (int x = 1; x < 10000; x++) {
        x_squared = x * x;
        for (int y = 1; x * x + x * y < 10000; y++) {
            y_squared = y * y;
            for (int z = 1; x_squared + y_squared + z * z + x * y < 10000; z++) 
                cnt[x_squared + y_squared + z * z + x * y + x * z + y * z]++;
        }
    }
    for (int i = 1; i <= n; i++)
        cout << cnt[i] << '\n';
    return 0;
}



Measured memory_bytes: 3680
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

N, K = read_ints()
is_okasi = [False] * N  # お菓子を持ってるスヌケ
for _ in range(K):
    read()
    A = read_ints()
    for a in A:
        is_okasi[a - 1] = True
# print(is_okasi)
print(N - sum(is_okasi))


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

bool overlap(int a, int b, int c, int d){
  assert( a < b ); assert( c < d );
  if ( d <= a ) return false;
  if ( b <= c ) return false;
  return true;
}

bool notOverlap(int a, int b, int c, int d){
  return b <= c || d <=a;
}

main(){
  int a, b, s, f, n;
  cin >> a >> b >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> s >> f;
    if ( overlap(a, b, s, f) ){
      cout << 1 << endl;
      return 0;
    } else {
      assert(notOverlap(a, b, s, f));
    }
  }
  cout << 0 << endl;
  return 0;
}




Measured memory_bytes: 3128
N=input()
N=int(N)
a=input()
a=a.split()
score=[0]*8
legend=0
inrank=0
a=[int(item) for item in a]
for i in range(0,N):
    p=int(a[i]/400)
    if p >= 8:
        legend+=1
    else:
        score[p]=1
inrank=score.count(1)
if legend!=0:
    if inrank==0:
        t_max=legend
        t_min=1
    else:
        t_max=inrank+legend
        t_min=inrank
else:
    t_max=inrank
    t_min=inrank
print(str(t_min)+" "+str(t_max))





Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class ALucky7 {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            for (char cc : c)
                if (cc == '7') {
                    w.println("Yes");
                    return;
                }
            w.println("No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25484
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {

	//Taking inputs of following format.
	int n;
	cin >> n;
	string s;
	cin >> s;
    
	int len = s.length();
	if (len <= n) {
		cout << s << endl;
	}
	else {
		for (int i = 0; i < n; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}

	return 0;
}

Measured memory_bytes: 3552
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    string ans;
    if (A > 8 || B > 8){
        ans = ":(";
    }else{
        ans = "Yay!";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.PrintStream;
import java.util.Scanner;
public class Main {
    private static final PrintStream ps = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        long sum = 0;
        long ans = 0;
        long xsum = 0;
        int r = 0;
        for (int l = 0; l < n; l++) {
            
            if (l != 0) {
                xsum ^= a[l-1];
                sum -= a[l-1];
            }
            while (true) {
                if (r >= n) {
                    ans += r - l;
                    break;
                }
                xsum ^= a[r];
                sum += a[r];
                
                if (xsum != sum) {
                  ans += r - l;
                  xsum ^= a[r];
                  sum -= a[r];
                  break;
                } 
                r++;
            }
        }
        ps.println(ans);
    }
}

Measured memory_bytes: 84760
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		if buf[0] == "0" {
			break
		}
		q1, _ := strconv.Atoi(buf[0]) // 買うべき鶏肉の量の下限(g)
		b, _ := strconv.Atoi(buf[1])  // 予算
		c1, _ := strconv.Atoi(buf[2]) // 会津地鶏の値段(/100g)
		c2, _ := strconv.Atoi(buf[3]) // 普通の鶏肉の値段(/100g)
		q2, _ := strconv.Atoi(buf[4]) // 会津地鶏の買える量の上限(g)
		maxAizuChiken := min(b/c1, q2)
		if maxAizuChiken <= 0 {
			fmt.Println("NA")
			continue
		}
		if c2 >= c1 {
			maxNormalChiken := (b - maxAizuChiken*c1) / c2
			if maxAizuChiken+maxNormalChiken < q1 { // 買い切ったけども必要な鶏肉の下限に達しなかった
				fmt.Println("NA")
			} else {
				fmt.Println(maxAizuChiken, maxNormalChiken)
			}
			continue
		}
		if (b-c1)/c2+1 < q1 { // 会津地鶏を1単位+普通の鶏肉を予算目一杯買ったが買うべき下限を超えなかった
			fmt.Println("NA")
			continue
		}
		// 二分探索
		low, high := 0, maxAizuChiken+1
		for high-low > 1 {
			mid := (low + high) / 2
			if check(mid, b, c1, c2, q1) {
				low = mid
			} else {
				high = mid
			}
		}
		fmt.Println(low, (b-low*c1)/c2)
	}
}

func check(mid, b, c1, c2, q1 int) bool {
	if mid+(b-mid*c1)/c2 < q1 {
		return false
	}
	return true
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}



Measured memory_bytes: 1100
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC148B - Strings with the Same Length

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String s = sc.next();
        String t = sc.next();

        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();
        StringBuffer sb = new StringBuffer("");

        for (int i = 0; i < n; i++) {
            sb = sb.append(cs[i]);
            sb = sb.append(ct[i]);
        }

        System.out.println(sb);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 87;
int dp[N][2];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> v;
    for (int i = n - 1; i >= 0; --i)
        v.push_back(s[i] - '0');
    v.push_back(0);
    int ans = 0;
    dp[0][0] = v[0];
    dp[0][1] = 10 - v[0];
    for (int i = 1; i <= n; ++i) {
        dp[i][0] = min(v[i] + dp[i - 1][0], v[i] + 1 + dp[i - 1][1]);
        dp[i][1] = min(10 - v[i] + dp[i - 1][0], 10 - (v[i] + 1) + dp[i - 1][1]);
    }
    cout << dp[n][0] << endl;
}


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

#define endl '\n'
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define SORT(v) sort(ALL(v))
#define SORTD(v) sort(ALL(v), greater<int>())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout<<x<<endl
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl
#define printu(v) for(auto i : v){print(i);}
#define readv(v, n) for (int i=0;i<n;i++)cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

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; }

void debug_print() {}

template <class Head, class... Tail>
void debug_print(Head&& head, Tail&&... tail)
{
	cout << (head) << endl;

	debug_print(forward<Tail>(tail)...);
}

int i, j, k;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double s = (double)w * h / 2.0;
	cout << fixed;
	if (w == x * 2 && h == y * 2) {
		cout << setprecision(6) << s << " " << 1 << endl;
	} else {
		cout << setprecision(6) << s << " " << 0 << endl;
	}
	return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int T[5123456];
int B[5123456];
int E=0;
int M=1;
typedef vector<int> V;
typedef vector<V> VV;
int n,v;
VV g;
vector<LL> x;
V build_graph(int vv,bool addedge=false){
    vector<int> ret;
    if(vv!=0)
    build_graph(vv/2,true);
    ret.pb(0);
    FOR(i,1,n){
        if(x[i]-x[i-1]>vv){
            if(addedge){
                T[E]=i;
                B[E]=M;
                g[ret.back()].pb(E++);
                //cout<<ret.back()<<" "<<T[E-1]<<" "<<B[E-1]<<endl;
            }
            ret.pb(i);
            
        }
    }
    if(addedge){
        T[E]=n;
        B[E]=M;
        g[ret.back()].pb(E++);
        //cout<<ret.back()<<" "<<T[E-1]<<" "<<B[E-1]<<endl;

        M++;
    }
    return ret;
}
int main(){
    cin>>n>>v;
    x.resize(n);
    g.resize(n+1);
    cin>>x;
    auto CC=build_graph(v);
    if(CC.size()>20){
        REP(i,n)cout<<"Impossible"<<fin;
    }
    else{
        CC.pb(n);
        REP(i,CC.size()-1){
            T[E]=CC[i+1];
            B[E]=0;
            g[CC[i]].pb(E);
            //cout<<CC[i]<<" "<<CC[i+1]<<" "<<B[E]<<endl;

            int top=0;
            vector<int> dp(1<<M,0);
            REP(bit,(1<<M)){
                chmax(top,dp[bit]);
                for(auto &e:g[dp[bit]]){
                    int nxtbit=bit|(1<<B[e]);
                    int cxtbit=bit^(1<<B[e]);
                    if(nxtbit==cxtbit)
                        chmax(dp[nxtbit],T[e]);
                }
            }
            g[CC[i]].pop_back();
            string res="Impossible";
            if(top==n)res="Possible";
            FOR(j,CC[i],CC[i+1])cout<<res<<fin;
        }
    }
    
    return 0;
}


Measured memory_bytes: 23264
#include <iostream>
#include <vector>
const int MOD = 1000000007;

void countPN(int n, std::vector<int> &count)//nを素因数に分解し、countを更新
{
	int m = n;
	for(int i=2 ; i*i<=n ; ++i)
	{
		while(m%i == 0)
		{
			m /= i;
			count[i]++;
		}
		if(m==1) break;
	}
	if(m!=1) count[m]++;

}

int main()
{
	int N; std::cin >> N;
	std::vector<int> count(1024);
	for(auto &x : count) x = 0;
	for(int n=2; n<=N; n++) countPN(n, count);

	long long ans = 1;
	for(int n=2; n<=N; n++)
	{
		if(count[n] != 0)
		{
			ans *= count[n]+1;
			ans %= MOD;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
class ModInt(x: Long) {

    companion object {
        const val MOD = 1e9.toLong() + 7
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun plus(other: Long): ModInt {
        return this + ModInt(other)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun minus(other: Long): ModInt {
        return this - ModInt(other)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun times(other: Long): ModInt {
        return this * ModInt(other)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun pow(exp: Int): ModInt {
        return pow(exp.toLong())
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}

fun main() {
    val n = readLine()!!.toInt()
    var zero = 0L
    val cnt = mutableMapOf<Pair<Long, Long>, Pair<Int, Int>>()
    repeat(n) {
        var (a, b) = readLine()!!.split(' ').map { it.toLong() }
        if (a == 0L && b == 0L) {
            zero++
            return@repeat
        }

        val g = gcd(a, b)
        a /= g
        b /= g
        if (a < 0) {
            a = -a
            b = -b
        }
        if (b > 0) {
            cnt[a to b] = (cnt[a to b] ?: 0 to 0).let { (a, b) -> a + 1 to b }
        } else {
            cnt[-b to a] = (cnt[-b to a] ?: 0 to 0).let { (a, b) -> a to b + 1 }
        }
    }

    var ans = ModInt(1L)

    val base = ModInt(2)
    for (key in cnt.keys) {
        val (c1, c2) = cnt[key]!!
        ans *= base.pow(c1) - 1 + base.pow(c2) - 1 + 1
    }
    ans -= 1
    ans += zero

    println(ans)
}


Measured memory_bytes: 95824
import numpy as np

a = input().split()
b = []
for i in range(int(a[0])):
  c = input().split()
  b.extend(c[1:])
count = 0
  
for j in range(int(a[1])+1):
  check = b.count(str(j))
  if check >= int(a[0]):
    count += 1

print(count)

Measured memory_bytes: 12392
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

S = s()
L = len(S)

if L == 2:
    if S[0] == S[1]:
        print 1, 2
    else:
        print -1, -1
else:
    for i in xrange(L - 2):
        if len(set(S[i:i + 3])) < 3:
            print i + 1, i + 2 + 1
            break
    else:
        print -1, -1


Measured memory_bytes: 4644