akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int n; cin >> n;
    int count[3] = {0};
    for(int i = 0; i < n; ++i){
        int a; cin >> a;
        if(!(a % 4)) ++count[0];
        else if(!(a % 2)) ++count[1];
        else ++count[2];
    }
    cout << (count[0] >= count[2] - !count[1] ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[float]", u: "List[str]"):
    ret = 0
    for i in range(N):
        if u[i] == "JPY":
            ret += x[i]
        else:
            ret += 380000.0 * x[i]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]" 
    u = [str()] * (N)  # type: "List[str]" 
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    solve(N, x, u)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
N = int(input())

sushi = np.bincount(np.array(input().split(), dtype=np.int8),minlength=4)
total = (sushi * np.arange(4)).sum()

# a,b,c = 1個、2個、3個
# S = a + 2b + 3c：total スシ
# S の小さい方から求めていく
# S ごとには、b,c だけ持てば a が分かる

b = np.arange(N+1)[:,None]
c = np.arange(N+1)[None,:]
S_bc = 2 * b + 3 * c
dp = np.zeros((N+1,N+1))
for S in range(1,total+1):
    prev = dp
    a = S - S_bc
    dp = prev * a + N
    dp[1:] += prev[:-1] * b[1:]
    dp[:-1,1:] += prev[1:,:-1] * c[:,1:]
    dp /= (a+b+c)
    dp[a < 0] = 0

answer = dp[sushi[2],sushi[3]]
print(answer)

Measured memory_bytes: 18592
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)


int arr[100005];
int dp[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    REP(i,n) cin>>arr[i];
    dp[0]=0;
    FOR(i,1,n-1){
        int ans=INT_MAX;
        FOR(j,1,min(i,k)){
            ans=min(dp[i-j]+abs(arr[i]-arr[i-j]),ans);
        }
        dp[i]=ans;
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
const int N = 110;
int n;
int a[N];

bool judge(int a, int b, int c)
{
	return a + b > c && a + c > b && b + c > a; 
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)	scanf("%d", &a[i]);
	
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i + 1; j <= n; j++)
		{
			if(a[j] != a[i])
			{
				for(int k = j + 1; k <= n; k++)
				{
					if(a[k] != a[j] && a[k] != a[i])
					{
						if(judge(a[i], a[j], a[k]))
						{
							ans++;
						}
					}
				}
				
			}
		}
	}
	
	printf("%d", ans); 
	return 0;
}



Measured memory_bytes: 3832
# AOJ 0503: Cup
# Python3 2018.6.29 bal4u

p3, c = [1]*16, [0]*16

for i in range(1, 16): p3[i] = 3*p3[i-1]
while True:
	n, m = map(int, input().split())
	if n == 0: break
	for i in range(3):
		a = list(map(int, input().split()))
		for j in range(a[0]): c[a[j+1]-1] = i
	ans = k = 0;
	for i in range(n):
		j = c[i]-k
		if j < 0: j = -j
		ans += j*p3[n-i-1]
		if j == 1: k = 2-k
	k = p3[n]-ans-1
	if ans > k: ans = k
	print(ans if ans <= m else -1)



Measured memory_bytes: 5596
T = [int(i) for i in input().split()]
if T[0] >= T[3] or T[2] >= T[1]:
  print(0)
elif T[0] >= T[2]:
  print(min(T[3] - T[0], T[1] - T[0]))
elif T[2] >= T[0]:
  print(min(T[3] - T[2], T[1] - T[2]))

Measured memory_bytes: 3064
k, n = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))

max_dis = 0
for i in range(n):
    if i < n - 1:
        dis = abs(a[i] - a[(i+1)%n])
    else:
        dis = a[0] + k - a[i]
    if max_dis < dis:
        max_dis = dis
print(k - max_dis)

Measured memory_bytes: 26996
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s,t; cin>>s>>t;
    vector<int> start(26,-1);
    vector<int> goal(26,-1);

    REP(i,s.size()){
        int a=s[i]-'a';
        int b=t[i]-'a';
        if(start[a]!=-1 or goal[b]!=-1){
            if(start[a]!=b or goal[b]!=a){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            start[a]=b;
            goal[b]=a;
        }
    }
    cout<<"Yes"<<endl;

}

Measured memory_bytes: 776
#!/usr/bin/env python
# coding: utf-8

# In[5]:


H,W,A,B = map(int, input().split())


# In[6]:


for i in range(H):
    if i < B:
        tmp = "0"*A + "1"*(W-A)
    else:
        tmp = "1"*A + "0"*(W-A)
    print(tmp)


# In[ ]:






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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  int x = 0, y = 0;
  rep(i,n) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      y++;
      x = max(x,y);
    }
    else y = 0;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  cin >> s;
  
  bool ans = true;
  
  rep(i,s.size()){
    if(i%2){
      if(s[i] == 'R') ans = false;
    }else{
      if(s[i] == 'L') ans = false;
    }
  }
  
  if(ans){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s;
	cin >>s;
	if (s=="ABC") cout <<"ARC";
	
	else cout <<"ABC";
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3628
M, N = map(int,input().split())

if M == 1 and N == 1:
    print(1)
elif M == 1:
    print(N - 2)
elif N == 1:
    print(M - 2)
else:
    print(M * N - ((M * N) - ((M - 2) * (N - 2))))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    LL ans = 0;
    for(LL i = 0; i < n; ++i){
        if(a[i] != b[i] && b[i] != c[i] && a[i] != c[i]){
            ans += 2;
        }else if(a[i] == b[i] && b[i] == c[i]){
        }else{
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;



int main(){
        string s;
        cin >> s;
        int N = s.length();
        long ans= 0;
  		int date=N-1;
        for(int i = N-1; i >= 0; i--){
            if(s[i] == 'B'){
   				ans += date -i;
              date--;
              
            }
        }
  	cout << ans;
        

}


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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,m; scanf("%d%d",&n,&m);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    priority_queue<int> pq;
    ll sum=0;
    rep(i,0,n){
        pq.push(a[i]);
        sum+=a[i];
    }
    rep(rot,0,m){
        int val=pq.top(); pq.pop();
        int nxt=val/2;
        sum-=val-nxt;
        pq.push(nxt);
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1276
#include <cstdio>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int mod=1e9+7;
int n,c[51][51],f[51][51][51],g[51][51][51];
int main(){
	cin>>n;
	ref(i,0,n)c[i][0]=1;
	ref(i,1,n)ref(j,1,i)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	ref(i,0,n-1)f[1][i-i/2][i/2]=n;
	ref(i,1,n){
		if(i>1)ref(i1,0,n-1)ref(i2,0,n-1-i1){
			f[i][i1][i2]=g[i][i1][i2];
			if(i1&&i2)(f[i][i1][i2]+=f[i][i1-1][i2-1])%mod;
		}
		ref(i1,0,n-1)ref(i2,0,n-1-i1)if(f[i][i1][i2]){
			ref(I,0,i1+i2){
				int s=1LL*c[n-i][I]*c[n-i-I][i1+i2-I]%mod*f[i][i1][i2]%mod;
				int op=max(0,I-i2),ed=min(I,i1);
				(g[i+i1+i2][i1-ed][I-ed]+=s)%=mod;
			}
		}
	}
	cout<<f[n][0][0]<<endl;
}

Measured memory_bytes: 1152
#include <cstdio>
long long n, a, c, ans=1, M=1e9+7;
int main() {
	scanf("%lld", &n);
	while(n--) {
		scanf("%lld", &a);
		if(a < 2*c+1) ans = ans * (c+1) % M;
		else c++;
	}
	while(c) ans = ans * c-- % M;
	printf("%lld", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  if(b>n) {
    cout << a*n/b << endl;
  }
  else if(b==1) {
    cout << 0 << endl;
  }
  else {
    n=b-1;
    cout << a*n/b-a*(n/b) << endl;
  }
}

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

int main(){
    int n; cin>>n; 
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
        }
    int t=0;
    int ans=10000;
    for(int i=0;i<n;i++){
        t=0;
        while(d.at(i)%2==0){
            d.at(i)/=2;
            t++;
            }
            ans=min(ans,t);
            }
        cout<<ans<<endl;
        }


Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-27 16:21:45
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; int64 k; cin >> n >> k;
  map<int, int64> cnt;
  
  for (int i = 0; i < n; ++i) {
    int a; int64 b; cin >> a >> b;
    cnt[a] += b;
  }

  int64 cur = 0;
  for (auto it = cnt.begin(); it != cnt.end(); ++it) {
    cur += it-> second;
    if (cur >= k) {
      cout << it-> first << endl; return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 4224
#include <iostream>

using namespace std;

int main() {
    int n; cin >> n;
    int p[10] = { 0 };
    int ans = 0;
    int maxI = 0, maxP = 0;
    for (int i = 0; i < n; i++) {
        int pi; cin >> pi;
        p[i] = pi;
        if (maxP < pi) {
            maxI = i;
            maxP = pi;
        }
    }
    for (int i = 0; i < n; i++) {
        if (i == maxI) ans += maxP / 2;
        else ans += p[i];
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int a, b;
  string s, t;
  while (true) {
    cin >> s;
    if(s == "-") break;
    cin >> a;
    for(int i=0; i<a; i++) {
      cin >> b;
      t = s.substr(0, b);
      s.erase(s.begin(), s.begin()+b);
      s = s+t;
      if(i+1 == a) cout << s << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3232
kx = list(map(int, input().split()))
k, x = kx[0], kx[1]
minimum = x - k + 1
maximum = x + k - 1
minimum = max(minimum, -1000000)
maximum = min(maximum, 1000000)
r = [i for i in range(minimum, maximum + 1)]
print(" ".join(list(map(str, r))))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    long long h[n];
    rep(i,n) cin >> h[i];
    sort(h,h+n);
    long long ans = 0;
    rep(i,n-k) ans+=h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
#import"bits/stdc++.h"
#define r(n) for(i=0;i<n;i++)
using namespace std;main(int N){cin>>N;int A[2*N],c[N+1]={},n,t,i;r(2*N)cin>>A[i];r(2*N)if(++c[A[i]]>N)cout<<"No",exit(0);cout<<"Yes";queue<int>s;r(N)if(A[i]==A[N+i])s.push(i);while(s.size()){n=s.front(),t=N+rand()%N;if(A[n]^A[t]&&A[t-N]^A[n+N])swap(A[n+N],A[t]),s.pop();}r(N)cout<<" "<<A[i+N];}

Measured memory_bytes: 6408
# A Point in a Triangle
import math
def simul_eq(a,b,c,d,e,f):
    # A = [[a,b],[d,e]]
    C = [c,f]
    detA = a*e - b*d
    # if detA == 0: raise # det(A) == 0.
    At = [[e,-b],[-d,a]]
    x = sum(map((lambda x,y: x*y), At[0], C)) / detA
    y = sum(map((lambda x,y: x*y), At[1], C)) / detA
    return (x,y)
ss = input().split()
while 1:
    x1,y1,x2,y2,x3,y3,xp,yp = map(float,ss)
    s,t = simul_eq(x2-x1, x3-x1, xp-x1, y2-y1, y3-y1, yp-y1)
    if 0 < s < 1 and 0 < t < 1 and 0 < s + t < 1:
        print('YES')
    else:
        print('NO')
    try: ss = input().split()
    except EOFError: break


Measured memory_bytes: 7464
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long res = 2019;
    long long l,r;
    cin>>l>>r;
    if(r-l >= 2019){

        cout<<0<<endl;
    }
    else{
        for(long long i = l;i<=r;i++)
            for(long long j = i+1;j<=r;j++){
                res = min(res,((i%2019)*(j%2019))%2019);
            }
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#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;}

typedef pair<ll,ll> P;
int main2() {
  int N = nextInt();
  int M = nextInt();
  vector<P> v;
  REP(i, N) v.push_back({nextInt(), 1});
  REP(i, M) {
    ll B = nextInt();
    ll C = nextInt();
    v.push_back({C, B});
  }

  sort(ALL(v), [](const P& a, const P& b) {
    return a.first > b.first;
  });

  int n = N;
  ll ans = 0;
  for (P p : v) {
    ll sel = min(p.second, (ll)n);
    ans += p.first * sel;
    n -= sel;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 6512
S = input()
a = S[:2]
b = S[2:]
# print(int(a), int(b))

if 1 <= int(a) <= 12 and 1 <= int(b) <= 12:
    print("AMBIGUOUS")
elif 1 <= int(a) <= 12 and (int(b) < 1 or int(b) > 12):
    print("MMYY")
elif 1 <= int(b) <= 12 and (int(a) < 1 or int(a) > 12):
    print("YYMM")
else:
    print("NA")

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  vi32 p(n); cin >> p;
  bool f = true;
  rep(k, n) if (p[k] != k + 1) f = false;
  if (f) yes();
  rep(i, n) repi(j, i + 1, n) {
    swap(p[i], p[j]);
    bool f = true;
    rep(k, n) if (p[k] != k + 1) f = false;
    if (f) yes();
    swap(p[i], p[j]);
  }
  no();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rgi register int
using namespace std;
int a;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>s;
	if(a>=3200)
		cout<<s<<endl;
	else
		cout<<"red"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N;
  cin >> N;
  vector<int> t(N+1), x(N+1), y(N+1);
  t.at(0) = 0;
  x.at(0) = 0;
  y.at(0) = 0;
  
  REP(i, 1, N+1) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  
  bool able_to_move = true;
  int distance = 0;
  int t_distance = 0;
  
  rep(i, N){
    distance = abs(x.at(i+1) - x.at(i)) + abs(y.at(i+1) - y.at(i));
    t_distance = t.at(i+1) - t.at(i);
    //cout << t_distance << "  " << distance << endl;
    if(!(distance <= t_distance && (t_distance - distance)%2 == 0)){
      able_to_move = false;
    }
  }
  
  if(able_to_move == true){
    cout << "Yes";
  }else{
    cout << "No";
  }
  

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define  inf 2e18
#define  mod 1000000007
#define  bg begin()
#define  en end()
#define  ll long long int
#define  pb push_back
#define  mp make_pair
#define  vi vector<int>
#define  vll vector<long long int>
#define  vpll vector<pair<long long int,long long int> >
#define  vpii vector<pair<int,int> >
#define  vstr vector<string>
#define  mpii map<int ,int>
#define  mpll map<long long int,long long int >
#define  max3(a,b,c) max(a,max(b,c))
#define  min3(a,b,c) min(a,min(b,c))
#define  w(t) ll t; cin>>t; while(t--)
#define  vin(v,n) for(int i=0;i<n;i++){cin>>x; v.pb(x);  }
#define  for0(i,n) for(int i=0;i<n;i++)
#define  for1(i,n) for(int i=1;i<=n;i++)
#define  forv(it,v) for(auto it=v.begin();it!=v.end();it++)
#define  mem(a,val) memset(a,val,sizeof(a))
#define  Sort(vec) sort(vec.begin(),vec.end())
#define  RSort(vec) sort(vec.rbegin(),vec.rend())
#define  eb emplace_back
#define  bs binary_search
#define  lb(v,a) lower_bound(v.begin(),v.end(),a)
#define  ub(v,a) upper_bound(v.begin(),v.end(),a)
#define  deb1(x) cerr<<#x<<": "<<x<<" "<<endl
#define  deb2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define  deb3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define  deb4(a, b, c, dp) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#dp<<": "<<dp<<endl
#define  FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define  yes "YES"
#define  no "NO"
#define  PI 3.141592653589793238462643383279502884L
ll Ceil(ll a, ll b) {return a / b + (a % b != 0);}
ll fastModExp(ll a, ll b) { ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
// 2- Dimensional vector:- vector<vector<int> > v(n, vector<int> (26, 0));

mpll mpx;

int main() {

    long double a, b;
    cin >> a >> b;
    long  double d = a * b;
    ll r = Ceil(d, 1);
    ll z = floor(d);
    if (r == z)
        cout <<  r << endl;
    else cout << r - 1 << endl;

    return 0;
}

Measured memory_bytes: 3732
n=int(input())
s=input()
ans=0
for i in range(0,10):
    a=s.find(str(i))    #findは文字列を検索して最初のインデックスを返す
    if a==-1:
        continue
    for j in range(0,10):
        b=s.find(str(j),a+1)
        if b==-1:
            continue
        for k in range(10):
            if s.find(str(k),b+1) != -1:
                ans+=1

print(ans)
           




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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        vector<long> p(n), q(n), init;
        for (auto &x : p) cin >> x;
        for (auto &x : q) cin >> x;

        init = p;
        sort(init.begin(), init.end());
        long a, b, x = 0, y = 0;
        do {
            x++;
            y++;
            if (init == p) a = x;
            if (init == q) b = y;
        } while (next_permutation(init.begin(), init.end()));

        long ans = abs(a - b);
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int n,ans;
int a[N],LOG[N],f[N][21];

inline int jay(int x,int y,int now)
{
	int s=(int)LOG[y-x+1];
	if (min(f[x][s],f[y-(1<<s)+1][s])==now) return true;
	return false;
}

signed main(){
	scanf("%lld",&n); 
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]);
	LOG[0]=-1;
	for (register int i=1; i<=n; ++i) LOG[i]=LOG[i>>1]+1;
	for (register int i=1; i<=n; ++i) f[i][0]=a[i];
	for (register int j=1; j<=20; ++j)
	for (register int i=1; i+(1<<j)-1<=n; ++i) f[i][j]=min(f[i][j-1],f[i+(1<<(j-1))][j-1]); 
	
	for (register int i=1; i<=n; ++i)
	{
		int l,r,pos1,pos2;
		l=1; r=i;
		while (l<=r)
		{
			int mid=l+r>>1;
			if (jay(mid,i,a[i])) pos1=mid,r=mid-1;
			else l=mid+1;	
		}
		l=i; r=n;
		while (l<=r)
		{
			int mid=l+r>>1;
			if (jay(i,mid,a[i])) pos2=mid,l=mid+1;
			else r=mid-1;
		}
		ans+=a[i]*(i-pos1+1)*(pos2-i+1);
	}
	printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 36224
import sys
from itertools import accumulate, islice

n, m, q = map(int, input().split())
ipt = (map(int, line.split()) for line in sys.stdin.readlines())
rails = [[0] * n for _ in range(n)]
for l, r in islice(ipt, m):
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(reversed(s))) for s in zip(*(accumulate(s) for s in rails))]
print('\n'.join(map(str, (rails[q - 1][n - p] for p, q in ipt))))


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

using namespace std;

const int MX = 3010;

long long dp[MX][MX][4];
long long v[MX][MX];

void solve() {
    int R, C, K;
    cin >> R >> C >> K;
    for (int i = 0; i < K; i++)
    {
        int r, c, val;
        cin >> r >> c >> val;
        r--; c--;
        v[r][c] = val;
    }
    
    for (int i = 0; i < MX; i++)
    {
        for (int j = 0; j < MX; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                dp[i][j][k] = LONG_LONG_MIN;
            }
            
        }
        
    }
    dp[0][0][0] = 0;

    for (int i = 0; i < R; i++)
    {
        for (int j = 0; j < C; j++)
        {
            for (int k = 2; k >= 0; k--)
            {
                if (dp[i][j][k] >= 0)
                {
                    dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k] + v[i][j]);
                }
            }
            for (int k = 0; k < 4; k++)
            {
                if (i + 1 < R)
                {
                    dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                }
                if (j + 1 < C)
                {
                    dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
                }
            }
            
        }
        
    }
    
    long long ans = LONG_LONG_MIN;
    for (int k = 0; k < 4; k++)
    {
        ans = max(ans, dp[R-1][C-1][k]);
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 357304
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

class Cake
{
public: 
    int x, y, z;
    long long val;
    Cake(int x, int y, int z, long long val)
    {
        this->x = x;
        this->y = y;
        this->z = z;
        this->val = val;
    }

    bool operator > (const Cake &other) const
    {
        return this->val < other.val;
    }
};


int main()
{
    int X, Y, Z, K;
    std::cin >> X >> Y >> Z >> K;

    std::vector<long long> A(X), B(Y), C(Z);
    for (int i = 0; i < X; ++i) { std::cin >> A[i]; }
    for (int i = 0; i < Y; ++i) { std::cin >> B[i]; }
    for (int i = 0; i < Z; ++i) { std::cin >> C[i]; }

    std::sort(A.begin(), A.end());
    std::sort(B.begin(), B.end());
    std::sort(C.begin(), C.end());

    std::priority_queue< Cake, std::vector<Cake>, std::greater<Cake> > queue;
    queue.push(Cake(X - 1, Y - 1, Z - 1, A[X - 1] + B[Y - 1] + C[Z - 1]));

    std::vector<bool> searched(X * Y * Z, false);
    for (int i = 0; i < K;)
    {
        Cake c = queue.top();
        queue.pop();
        if (searched[c.x * (Y * Z) + c.y * (Z) + c.z])
        {
            continue;
        }

        std::cout << c.val << std::endl;

        searched[c.x * (Y * Z) + c.y * (Z) + c.z] = true;

        if (c.x > 0) { queue.push(Cake(c.x - 1, c.y, c.z, A[c.x - 1] + B[c.y] + C[c.z])); }
        if (c.y > 0) { queue.push(Cake(c.x, c.y - 1, c.z, A[c.x] + B[c.y - 1] + C[c.z])); }
        if (c.z > 0) { queue.push(Cake(c.x, c.y, c.z - 1, A[c.x] + B[c.y] + C[c.z - 1])); }

        i++;
    }

    return 0;
}


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

signed main() {
  int N, H; cin >> N >> H;
  vector<pair<int,int>> k(N);
  rep(i, N) {
    int a, b; cin >> a >> b;
    k[i] = make_pair(a, b);
  }
  
  sort(all(k));
  reverse(all(k));
  int A = k[0].first, B = k[0].second;
  k[0].second = 0;
  
  vector<int> b(N);
  rep(i, N) b[i] = k[i].second;
  sort(all(b));
  reverse(all(b));
  
  int i = 0;
  H -= B;
  int ans = 0;
  if(H <= 0) {
    cout << ans+1 << endl;
    return 0;
  }
  while(b[i] >= A) {
    H -= b[i];
    i++;
    ans++;
    if(H <= 0) {
      cout << ans+1 << endl;
      return 0;
    }
  }
  cout << ans+1+(H+A-1)/A << endl;



}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
lint MOD = 1000000007;

template <typename T>
T power(T x, T n, T mod) {
    T ans = 1;
    while (n>0)
    {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

int N;
lint K;

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

    vector<lint> divs;
    for (int d=1; d*d<=N; d++)
    {
        if (N % d == 0) divs.push_back(d);
    }
    for (int i = divs.size()-1; i>=0; i--)
    {
        if (divs.back() != N / divs[i]) divs.push_back(N / divs[i]);
    }

    vector<lint> w(divs.size());

    lint ans = 0;
    for (int i=0; i<divs.size(); i++)
    {
        lint d = divs[i];
        lint tmp = power(K, (d + 1)/2, MOD);
        for (int j=0; j<i; j++)
        {
            if (divs[i] % divs[j]) continue;
            tmp = (tmp - w[j] + MOD) % MOD;
        }
        w[i] = tmp;
        ans = (ans + tmp * ((d&1) ? d : d/2 )) % MOD; 
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int H,N;
    cin>>H>>N;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        H=H-x;
    }
    if(H<=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> grid(H,vector<char>(W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> grid.at(i).at(j);
        }
    }

    vector<bool> lineall(H,0), rowall(W,0);

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(grid.at(i).at(j)=='#'){
                lineall.at(i) = 1;
                break;
            }
        }
    }
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            if(grid.at(j).at(i)=='#'){
                rowall.at(i) = 1;
                break;
            }
        }
    }

    for(int i=0;i<H;i++){
        if(lineall.at(i)==1){
            for(int j=0;j<W;j++){
                if(rowall.at(j)==1){
                    cout << grid.at(i).at(j);
                }
            }
            cout<<endl;
        }
    }
}




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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    rep(i,s.length()) {
        s[i] = s[i] + n;
        if(s[i] > 'Z') {
            s[i] = s[i] -'Z';
            s[i] = s[i] + 'A' - 1;
        }
    }

    cout << s << endl;
}

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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

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

const int mod = 998244353;
const int MAX = 200005;
const int INF = 1001001001;

int main(int, char**)
{
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

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

    int ans = 0;
    rep(i,k) ans += a[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
// template<class T> T gabs(const T& x) { return max(x, -x); }
// #define abs gabs

using P = pair<int, int>;
int h, w, n;
set<P> ps;
set<P> vis;
int f(int a, int b) {
    if (vis.count({a, b})) {
        return 0;
    }
    vis.insert({a, b});
    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            int s = a + i, t = b + j;
            if (s <= 0 || h < s || t <= 0 || w < t) {
                return 0;
            }
            cnt += ps.count({s, t});
        }
    }
    return cnt;
}

int main() {
    cin >> h >> w >> n;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ps.insert({a, b});
    }

    i64 ans[10] = {};
    for (auto p : ps) {
        for (int i = -2; i <= 0; ++i) {
            for (int j = -2; j <= 0; ++j) {
                int a = p.first + i, b = p.second + j;
                ans[f(a, b)]++;
            }
        }
    }
    ans[0] = (h - 2) * (w - 2);
    for (int i = 1; i <= 9; ++i) ans[0] -= ans[i];

    for (int i = 0; i <= 9; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long h,w,mod=1e9+7;
  cin >> h >> w;
  char c[h][w];
  long long dp[h+3][w+3]={};
  dp[0][0]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
      if(c[i][j]=='#'){
        dp[i][j]=0;
      }else{
        if(i>0){
          dp[i][j]+=dp[i-1][j];
          dp[i][j]%=mod;
        }
        if(j>0){
          dp[i][j]+=dp[i][j-1];
          dp[i][j]%=mod;
        }
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}


Measured memory_bytes: 9088
# 2019/11/27

edge=[[] for _ in range(4)]
for _ in range(3):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edge[a].append(b)
    edge[b].append(a)

odd=0
for c in edge:
    if len(c)%2:odd+=1
print('YES' if odd==2 else 'NO')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, n; cin >> h >> n;
    vector<int> a(n);
    int sum = 0;
    for(int i=0; i<n; ++i){cin >> a[i]; sum += a[i];}
    if(sum>=h){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 3656
use std::io::*;

fn main() {
    let stdin = stdin();
    let mut handle = stdin.lock();
    let h: u64 = read(&mut handle);
    let w: u64 = read(&mut handle);
    let mut hw = h * w;
    if hw % 2 == 0 {
        hw /= 2;
    } else {
        hw = hw / 2 + 1;
    }
    if h == 1 || w == 1 {
        hw = 1;
    }
    println!("{}", hw);
}

fn read(handle: &mut StdinLock) -> u64 {
    handle
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |acc, x| (x as u8 - b'0') as u64 + acc * 10)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }








int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    ll P[70];
    P[0] = 1;
    rep3(i, 1, 70) P[i] = P[i - 1] * 2 % inf;
    
    ll n = 300000;
    cin >> n;
    vector<ll> a(n);
    // rep(i, n) a[i] = (1LL << 60) - (i + 1);
    rep(i, n) cin >> a[i];
    
    ll ans = 0;
    rep(i, n) (ans += a[i] % inf * (n - 1)) %= inf;
    
    vector<ll> table(70);
    rep(i, n) {
        int keta = 0;
        while (a[i]) {
            if (a[i] % 2) table[keta]++;
            keta++;
            a[i] /= 2;
        }
    }
    
    ll tmp = 0;
    rep(i, 70) {
        if (table[i] >= 2) (tmp += P[i] * table[i] % inf * (table[i] - 1)) %= inf;
    }
    
    ans = (ans - tmp + inf) % inf;
    
    cout << ans << endl;
}



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

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

	string	s;
	cin >> s;

	int	count;
	count = 1;
	int	before_len;
	before_len = 1;
	for (int i = 1; i < s.size();)
	{
		if (before_len == 1 && s.at(i - 1) == s.at(i))
		{
			if (i == s.size() - 1)
				break;
			else
			{
				before_len = 2;
				i += 2;
			}
		}
		else
		{
			before_len = 1;
			i++;
		}
		count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,d,e,f,g,h,i;
    cin>>a>>b>>c>>d;
    e=a*c;
    f=a*d;
    g=b*c;
    h=b*d;
    i=max({e,f,g,h});
    cout<<i<<endl;
}


Measured memory_bytes: 3632
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

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

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) print("Possible");
    else print("Impossible");
}

Measured memory_bytes: 3624
import math

def is_prime(n):
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return n != 1

n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_prime(m):
        answer = answer + 1
print(answer)


Measured memory_bytes: 5756
#include<iostream>
using namespace std;
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    int seq[99];
    for (int i = 0; i < n - 1; i++) cin >>seq[i];
    int sum = 0;
    for (int i = 0; i < n - 1 ; i++) {
        if (i > 0) {
            if (seq[i-1] < seq[i]) {sum += seq[i-1];}
            else {sum += seq[i];}
        } else {
            sum += seq[0];
        }
    }
    sum += seq[n - 2];
    cout << sum;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
int main(){
	long long N, M;
	long long work, work1;
	long long cnt = 0;
	cin >> N >> M;
 
	work = N;
	work1 = M;
	work1 -= work * 2;
	if(work1 < 0){
		cout << (M / 2) << endl;
		return 0;
	}
	cnt = work;
	cnt += work1 / 4;
	cout << cnt << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<utility>
#include<random>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

bool ischara(char t) {
	if ('a' <= t && t <= 'z')return true;
	if ('A' <= t && t <= 'Z')return true;
	return false;
}
bool isnum(char t) {
	if ('0' <= t && t <= '9')return true;
	return false;
}
typedef pair<char, int> speP;
int main() {
	while (true) {
		map<char, int> mp;
		map<char, bool> used;
		map<speP, bool> exi;
		map<speP, int> ret;
		vector<string> v;
		string s;
		while (cin >> s) {
			if (s == ".")break;
			v.push_back(s);
		}
		if (v.size() == 0)break;
		int num = 0; int ans = 0;
		rep(i, v.size()) {
			speP mem;
			bool theequal = false;
			stack<char> st;
			rep(j, v[i].size()) {
				char t = v[i][j];
				if (ischara(t)) {
					st.push(t);
				}
				else if (isnum(t)) {
					int loc = j;
					while (j + 1 < v[i].size() && isnum(v[i][j + 1])) {
						j++;
					}
					num = stoi(v[i].substr(loc, j - loc + 1));
				}
				else if (t == ']') {
					char z = st.top(); st.pop();
					if (!used[z]) {
						used[z] = true;
						mp[z] = num;
					}
					else {
						if (num >= mp[z]) {
							ans = i + 1; break;
						}
						if (!exi[{z, num}]) {
							if (st.size() > 0) {
								ans = i + 1; break;
							}
							else {
								if (theequal) {
									ans = i + 1; break;
								}
								else {
									mem = { z,num };
								}
							}
						}
						else {
							if (st.size() == 0&&!theequal) {
								mem = { z,num };
							}
							num = ret[{z, num}];
						}
					}
				}
				else if (t == '=') {
					theequal = true;
				}
			}
			if (theequal) {
				exi[mem] = true; ret[mem] = num;
			}
			if (ans > 0)break;
		}
		cout << ans << endl;
	}
	//stop
	return 0;
}


Measured memory_bytes: 3220
import Data.List

showp (x,y) = unlines [show x, show y]
allEq xs = and $ zipWith (==) xs (tail xs)
fact n = product [1 .. fromIntegral n]
comb n r = div (fact n) (fact r * fact (n-r)) 

main = do
 [n,a,b] <- map read . words <$> getLine
 vs <- map read . words <$> getLine :: IO [Integer]
 putStrLn $ showp (mas n a b vs)

mas n a b vs
 | allEq inita && allEq initb = (ave, sum (map (comb lmax) [a .. min b lmax]))
 | allEq inita = (ave, sum (map (comb lmax) [a .. a + lminInitb]))
 | otherwise = (ave, comb (length (filter (== last inita) svs)) lminInita)
 where
  svs@(maxv:_) = sortBy (flip compare) vs
  inita = take a svs
  lminInita = length $ filter (== last inita) inita
  initb = take b svs
  lminInitb = length $ takeWhile (== last inita) (drop a initb)
  lmax = length $ head $ group svs
  ave = fromIntegral (sum (take a svs)) / fromIntegral a

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

class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		Long K = in.nextLong();
		Map<Long, Long> map = new TreeMap<>();
		for(int i=0;i<N;i++) {
			long ai = in.nextLong();
			long bi = in.nextLong();
			if(map.containsKey(ai) == false) {
				map.put(ai,bi);
			} else {
				map.put(ai, map.get(ai) + bi);
			}
		}
		Iterator<Long> it = map.keySet().iterator();
		long num = 0;
		long ans = 0;
		while(it.hasNext()) {
			Long key = it.next();
			num += map.get(key);
			ans = key;
			if(num >= K) {
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 96792
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

L = [a1,b1,a2,b2,a3,b3]

for i in range(1,5) :
    if L.count(i) >= 3 :
        ans = "NO"
        break
else :
    ans = "YES"

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string T;
    cin >> T;
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++){
        cin >> S[i];
        S[i] += S[i];
    }
    int cnt = 0;
    for(int i=0; i<N; i++){
        bool ok = false;
        for(int j=0; j<S[i].size(); j++){
            if(S[i].substr(j,T.size()) == T) ok = true;
        }
        if(ok) cnt++;
    }
    cout << cnt << enld;
    return 0;
}


Measured memory_bytes: 3180