akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 60;

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

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

constexpr ll MAX{100010};
ll n;
ll h[MAX];

ll dp[MAX];

int main(int argc, char **argv)
{
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> h[i];

	for (int i = 0; i < MAX; ++i) dp[i] = INF;

	dp[0] = 0;

	// loop
	for (int i = 1; i < n; ++i)
	{
		chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
		if (i > 1) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
	}

	std::cout << dp[n-1]<< std::endl;
}

Measured memory_bytes: 1792
#这个也是在模拟，不过是吧骰子反转到正面和侧面一样 (⊙o⊙)？，不知道有没有简单的方法
start = [0,1,2,4,3,5]#上 正 右 后 左 下
s = []
#下面的是几个反转方式
def N():
    start[0],start[1],start[3],start[5] = \
    start[1],start[5],start[0],start[3]
    
def S():
    start[0],start[1],start[3],start[5] = \
    start[3],start[0],start[5],start[1]
    
def W():
    start[0],start[2],start[4],start[5] = \
    start[2],start[5],start[0],start[4]

def E():
    start[0],start[2],start[4],start[5] = \
    start[4],start[0],start[5],start[2]    


#这是特殊的旋转方法
def roll():
    start[1],start[2],start[3],start[4] = \
    start[4],start[1],start[2],start[3]          

def get_top():
    return s[start[0]]

def get_zhengMian():
    return s[start[1]]

def get_right():
    return s[start[2]]

def get_left():
    return s[start[4]]

if __name__=='__main__':
    s = list(map(int,input().split()))
    num = int(input())
    for i in range(num):
        a,b = map(int,input().split())
        if a!=get_top():
            right =get_right()
            left = get_left()
            top = get_top()
            if(a==right):
                W()
            elif a==left:
                E()
            while a!=top:
                S()
                top = get_top()
        zhengmian = get_zhengMian()
        right = get_right()
        if b!=zhengmian:
            while b!=zhengmian:
                roll()
                zhengmian = get_zhengMian()
        print(get_right())


Measured memory_bytes: 5612
def read():
    return int(input())

RANKS = [(599, 8),
         (799, 7),
         (999, 6),
         (1199, 5),
         (1399, 4),
         (1599, 3),
         (1799, 2),
         (1999, 1)]

def ans(X):
    for th, r in RANKS:
        if X <= th:
            return r

if __name__ == '__main__':
    X = read()
    print(ans(X))

Measured memory_bytes: 61732
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

struct modint {
  i64 a;
  static i64& M() {
    static i64 mod_ = 2999;
    return mod_;
  }
  modint(const i64 x = 0) noexcept: a((x % M() + M()) % M()) {}
  i64 value() const noexcept { return a; }
  modint& operator=(const i64 r) {
    a = (r % M() + M()) % M();
    return *this;
  }
  modint& operator+=(const modint r) noexcept {
    a += r.a;
    if(a >= M()) a -= M();
    return *this;
  }
  modint& operator-=(const modint r) noexcept {
    a -= r.a;
    if(a < 0) a += M();
    return *this;
  }
  modint& operator*=(const modint r) noexcept {
    a = a * r.a % M();
    return *this;
  }
  modint& operator/=(modint r) noexcept {
    i64 ex = M() - 2;
    while(ex) {
      if(ex & 1) {
        *this *= r;
      }
      r *= r;
      ex >>= 1;
    }
    return *this;
  }

  modint operator+(const modint r) const {
    return modint(*this) += r;
  }
  modint operator-(const modint r) const {
    return modint(*this) -= r;
  }
  modint operator*(const modint r) const {
    return modint(*this) *= r;
  }
  modint operator/(const modint r) const {
    return modint(*this) /= r;
  }
};

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
 
template<const i64 N, const i64 M>
struct matrix {
  using T = modint;
  vector<vector<T>> mat;
  matrix(T init = T()): mat(N, vector<T>(M, init)) {}
  vector<T>& operator[](i64 i) { return mat[i]; }
  const vector<T>& operator[](i64 i) const { return mat[i]; }
  static matrix<N, N> E() {
    matrix<N, N> mat(0);
    rep(i,0, N) mat[i][i] = 1;
    return mat;
  }
};
template<const i64 L, const i64 M, const i64 N>
matrix<L, N> operator*(const matrix<L, M>& lm, const matrix<M, N>& rm) {
  matrix<L, N> ret;
  rep(i, 0, L) rep(j, 0, M) rep(k, 0, N) (ret[i][k] += lm[i][j] * rm[j][k]);
  return ret;
}
 
template<const i64 N>
matrix<N, N> matrix_pow(matrix<N, N> mat, i64 r) {
  matrix<N, N> ret = matrix<N, N>::E();
  while(r > 0) {
    if(r & 1) ret = ret * mat;
    mat = mat * mat;
    r >>= 1;
  }
  return ret;
}

int main() {
  i64 L, A, B, M;
  cin >> L >> A >> B >> M;
  modint::M() = M;

  i64 ten = 1;

  matrix<1, 3> mat;
  mat[0][0] = modint(0);
  mat[0][1] = modint(A);
  mat[0][2] = modint(1);
  rep(i,1,19) {
    ten *= 10;
    if(A < ten) {
      i64 x = (ten - A - 1) / B + 1;
      x = min(x, L);
      L -= x;
      matrix<3, 3> p;
      p[0] = { ten, 0, 0 };
      p[1] = { 1, 1, 0 };
      p[2] = { 0, B, 1 };
      mat = mat * matrix_pow(p, x);
      A = A + x * B;
    }
  }

  cout << mat[0][0].value() << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int N,A,B,i,m;
    cin >> N;
    A=1000;
    i = N/A;
    if(N%A){
        if(N>A) {
        B = A * (i+1);
        m = B - N;
        cout << m << endl;
        }
        else {
            m = A - N;
            cout<< m << endl;
        }
    }
    else if(N/A) cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    ll n;
    cin>>n;
    ll a[n],i,t=0;
    forn(i,n){
        cin>>a[i];
        t^=a[i];
    }
    forn(i,n){
        cout<<(t ^ a[i])<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 5076
n = int(input())
inp = list(map(int, input().split()))
length = len(inp)
ans = 0
curr_max = 0
for i in range(-1,-length,-1):
    if inp[i] <= inp[i-1]:
        ans += 1
        if ans > curr_max:
            curr_max = ans
    else:
        ans = 0
print(curr_max)

Measured memory_bytes: 15020
#include <bits/stdc++.h> 
using namespace std;
int minimumChar(string S1, string S2)
{ 
    long long res = INT_MAX;
    for (int i = 0; i < S1.size() - S2.size() + 1; i++) {
        long long minchar = 0;
        for (int j = 0; j < S2.size(); j++) {
            if (S2[j] != S1[i + j]) {
                minchar++;
            }
        }
       res = min(minchar, res);
    }
    return res;
}

int main()
{
    string S1; cin >> S1;
    string S2; cin >> S2;

    cout << minimumChar(S1, S2);

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s;
set<string> st;

int main(){
	cin>>n>>s;
	bool B=1;
	st.insert(s);
	for(int i=1;i<n;i++){
		string t;
		cin>>t;
		if(s.back()!=t[0]||st.find(t)!=st.end()) B=0;
		s=t;
		st.insert(s);
	}
	cout<<(B?"Yes":"No")<<endl;
}

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

using namespace std;

using ll = long long;

const int mod = 1000000007;
class modint {
public:
    ll a = 0;
    modint(ll x = 0) {while(x < 0)x += mod;a = x%mod;}
    modint(const modint &r) {a = r.a;}
    modint operator -(){return modint(-a);}
    modint operator +(const modint &r) {return modint(*this)+=r;}
    modint operator -(const modint &r) {return modint(*this)-=r;}
    modint operator *(const modint &r) {return modint(*this)*=r;}
    modint &operator +=(const modint &r){
        a += r.a;
        if(a >= mod) a -= mod;
        return *this;
    }
    modint &operator -=(const modint &r) {
        a -= r.a;
        if(a < 0) a += mod;
        return *this;
    }
    modint &operator *=(const modint &r) {
        a = a * r.a % mod;
        return *this;
    }
    modint pow(ll r) const {
        if (!r) return 1;
        modint x = pow(r >> 1);
        x *= x;
        if (r & 1) x *= *this;
        return x;
    }
    modint inverse() const {
        return pow(mod-2);
    }
    modint& operator/=(const modint r) {
        return (*this) *= r.inverse();
    }
    modint operator/(const modint r) const {
        modint res(*this);
        return res /= r;
    }
};
istream &operator>>(istream &is, modint &x) {
    ll t;
    is >> t;
    x = t;
    return is;
}
ostream &operator<<(ostream &os, const modint& x) {
    return os << x.a;
}
const int MAX = 1e6 + 8;
modint fac[MAX], inv[MAX], finv[MAX];
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * modint(i);
        inv[i] = - inv[mod%i] * modint(mod/i);
        finv[i] = finv[i-1] * inv[i];
    }
}
modint Com(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
modint Per(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k];
}

using Mint = modint;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cominit();
   int n;
   scanf("%d", &n);
   Mint zero = Mint(9).pow(n);
   Mint nine = zero;
   Mint zero_and_nine = Mint(8).pow(n);
   Mint ans = Mint(10).pow(n) - (zero + nine - zero_and_nine);
   cout << ans << endl;
}

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

long long int n, m;
vector<pair<long long int, long long int>> v;

int main()
{
    cin >> n >> m;
    v.resize(n);
    for (long long int i = 0; i < n; i++)
        cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());
    /*for (long long int i = 0; i < n; i++)
        cout << (v[i].first) << " " << (v[i].second) << endl;*/
    long long int i, sum = 0, ans = 0;
    for (i = 0; i < n && m > sum; i++)
    {
        sum += v[i].second;
        ans += v[i].second * v[i].first;
        //cout << i << " : " << sum << " " << ans << endl;
    }
    i--;
    //cout << sum << " " << m << " " << (m - sum) << endl;
    ans += v[i].first * (m - sum);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0

_a = A[0]
if _a > x:
    cnt += _a - x
    _a = x

for a in A[1:]:
    if _a + a > x:
        dif = _a + a - x
        cnt += dif
        _a = a - dif
    else:
        _a = a

print(cnt)

Measured memory_bytes: 14132
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

// ref: https://codeforces.com/blog/entry/77148?#comment-619728

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vector<pii> pve,nve;

    string s;
    int cnt,len;
    pii p;
    for(int i=0;i<n;++i)
    {
        cin>>s;
        len=sz(s);

        cnt=0;
        for(int j=0;j<len;++j)
        {
            if(s[j]=='(')
                ++cnt;
            else if(cnt)
                --cnt;
        }
        p.S=cnt;        // unbalanced "("

        cnt=0;
        for(int j=len-1;j>=0;--j)
        {
            if(s[j]==')')
                ++cnt;
            else if(cnt)
                --cnt;
        }
        p.F=cnt;        // unbalanced ")"

        if(p.S-p.F>=0)
            pve.pb(p);
        else
            nve.pb(p);
    }

    sort(all(pve),[](pii a,pii b){return a.F<b.F;});
    sort(all(nve),[](pii a,pii b){return a.S>b.S;});

    vector<pii> a;
    a.reserve(n);
    a.insert(end(a),all(pve));
    a.insert(end(a),all(nve));

    int sum=0;
    for(auto c:a)
    {
        sum-=c.F;

        if(sum<0)
        {
            cout<<"No";
            return;
        }

        sum+=c.S;
    }

    if(sum)
        cout<<"No";
    else
        cout<<"Yes";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 34608
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n+1;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
#define stringc(s) string s; cin >> s;
using namespace std;
int main() {
  intc(k);
  int m;
  ll a=0;
  r2(i,k) {
    r2(j,k) {
      r2(l,k) {
        m=gcd(j, l);
        a+=gcd(i, m);
      }
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 3636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,c,d = inpl()
if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define INF 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int h,w;
char a[1000][1000];
ll memo[1000][1000];
bool ok[1000][1000];
ll dp(ll y,ll x){
  ll res = 0;
  if(ok[y][x])return memo[y][x];
  if(y != 0 && a[y - 1][x] == '.')res += dp(y - 1,x) % INF;
  if(x != 0 && a[y][x - 1] == '.')res += dp(y,x - 1) % INF;
  ok[y][x] = true;
  return memo[y][x] = res % INF;
}
int main(){
  cin >> h >> w;
  rep(i,h)rep(j,w)cin >> a[i][j];
  memo[0][0] = 1;
  ok[0][0] = true;
  dp(h - 1,w - 1);
  cout << memo[h - 1][w - 1] % INF << endl;
  return 0;
}


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

int main()
{
    int k, a, b;
    int flag = 0;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++)
    {
        if(i % k == 0)
        {
            flag = 1;
            break;
        }
    }
    if(flag == 1)
    {
        cout << "OK";
    }
    else
    {
        cout << "NG";
    }
    
       
    return 0;
}

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

int main(){
	int h,w;
	cin >> h >> w;
	while(h!=0 || w!=0){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if((i+j)%2==0){
					cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
}

Measured memory_bytes: 1156
#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 _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;

int main() {
    ll n,m;
    cin>>n>>m;
    ll a[m];
    rep(i,m){
        cin>>a[i];
        n-=a[i];
    }
    cout<<max(n,ll(-1))<<endl;


    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int n = 1;
  for (int i; i < N; i ++ ){
    if (n < K){
      n *= 2;
    }
	else{
      n += K;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int a,b,c,k;
  cin >> a >> b >> c;
  cin >> k;
  if(a>b&&a>c){rep(i,k)
    a=a*2;
    printf("%d",a+b+c);
              }
  else if(b>c){rep(i,k)
    b=b*2;
    printf("%d",a+b+c);
              }
  else{rep(i,k)
    c=c*2;
    printf("%d",a+b+c);
              }
}

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

using ll=long long;
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int s,t;
    int i=0;
    bool flag=true;
    if(a%2==1 || b%2==1 || c%2==1) cout<<0<<endl;
    else if(a==b && b==c) cout<<-1<<endl;
    else{
        while(flag){
            s=a;
            t=b;
            a=b/2+c/2;
            b=s/2+c/2;
            c=s/2+t/2;
            i++;
            if(a%2==1 || b%2==1 || c%2==1) flag=false;
        }
        cout<<i<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3592
def main():
    (n,k),p,c=[[*map(int,t.split())]for t in open(0)]
    m=-10**18
    for i in range(n):
        s=i
        t=1
        x=c[s]
        while p[s]-1!=i:
            s=p[s]-1
            t+=1
            x+=c[s]
        if x>0:
            a=(k//t-1)*x
            if a>m:m=a
            s=i
            for _ in range(k%t+t):
                s=p[s]-1
                a+=c[s]
                if a>m:m=a
        else:
            a=0
            s=i
            for _ in range(min(k,t)):
                s=p[s]-1
                a+=c[s]
                if a>m:m=a
    print(m)
main()

Measured memory_bytes: 68540
#include <bits/stdc++.h>
using namespace std;
vector <int> crock, cempty;
int n;

void precomp(string a)
{
	for (int i = 0; i < n - 2; i++)
	{
		if (a[i] == '#' && a[i + 1] == '#') crock.push_back(i + 1);
		if ((a[i] == '.' && a[i + 1] == '.') && a[i + 2] == '.') cempty.push_back(i + 1);
	}
	
	if (a[n - 1] == '#' && a[n - 2] == '#') crock.push_back(n - 1);
}

inline bool possible(int c, int d)
{
	if (lower_bound(crock.begin(), crock.end(), c) == crock.end()) return true;
	if (*lower_bound(crock.begin(), crock.end(), c) > d) return true; 
	else return false;
}

inline bool meow(int c, int d)
{
	if (lower_bound(cempty.begin(), cempty.end(), c - 1) == cempty.end()) return false;
	if (*lower_bound(cempty.begin(), cempty.end(), c - 1) >= d) return false; 
	else return true;
}

int main() 
{
	int a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	string str;
	cin >> str;
	precomp(str);
	
	if (c < d) 
	{
		if (possible(b, d) && possible(a, c)) cout << "Yes";
		else cout << "No";
	}
	
	else
	{
		if (possible(b, d) && possible(a, c)) 
		{
			if (meow(b, d)) cout << "Yes"; 
			else cout << "No";
		}	
		else cout << "No";
	}
}

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

using namespace std;

int solve(vector<int> &a)
{
    int N = a.size();
    const int p[] = {5, 7, 5, 7, 7};
    for (int i = 0; i < N; i++) {
        bool poss = 1;
        int q = i;
        for (int j = 0; j < 5; j++) {
            int sum = 0;
            for (; q < N; ) {
                sum += a[q++];
                if (sum >= p[j]) break;
            }
            if (sum != p[j]) {
                poss = 0;
                break;
            }               
        }
        if (poss) {
            return i + 1;
        }
    }
    return -1;
}

int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> a(N);
        string s;
        for (int i = 0; i < N; i++) {
            cin >> s;
            a[i] = s.size();
        }
        cout << solve(a) << endl;
    }
    return 0;
}

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

int main() {
    vector<string> v[3];
    for(int i=0; i<3; ++i) {
        while(true) {
            char c;
            cin >> c;
            if(c != '$') {
                v[i].push_back(string{c});
                string len;
                cin >> len;
                v[i].push_back(len);
            } else {
                break;
            }
        }
    }
    auto A = v[0], B = v[1], C = v[2];
    vector<string> res;
    for(int i=0; i<A.size(); i += 2) {
        if(A[i] == B[0] && stoi(B[1]) <= stoi(A[i+1])) {
            bool ok = B.size() == 2;
            for(int j=2; i+j+1<A.size() && j+1<B.size(); j += 2) {
                if(j == B.size() - 2) {
                    if(A[i+j] == B[j] && stoi(A[i+j+1]) >= stoi(B[j+1])) {
                        ok = true;
                        break;
                    }
                } else if(A[i+j] != B[j] || stoi(A[i+j+1]) != stoi(B[j+1])) {
                    break;
                }
            }
            if(ok) {
                for(int j=0; j<i; ++j) {
                    res.push_back(A[j]);
                }
                if(B.size() != 2 && stoi(A[i+1]) - stoi(B[1]) > 0) {
                    res.push_back(A[i]);
                    res.push_back(to_string(stoi(A[i+1]) - stoi(B[1])));
                }
                res.push_back(C[0]);
                res.push_back(C[1]);
                for(int j=2; j<C.size(); ++j) {
                    res.push_back(C[j]);
                }
                if(stoi(A[i+B.size()-1]) > stoi(B[B.size()-1])) {
                    res.push_back(A[i+B.size()-2]);
                    res.push_back(to_string(stoi(A[i+B.size()-1]) - stoi(B[B.size()-1])));
                }
                for(int j=i+B.size(); j<A.size(); ++j) {
                    res.push_back(A[j]);
                }
                break;
            }
        }
    }
    if(res.empty()) {
        res = A;
    }
    for(int i=0; i+1<res.size(); i+=2) {
        while(i + 3 < res.size() && res[i+2] == res[i]) {
            res[i+3] = to_string(stoi(res[i+3]) + stoi(res[i+1]));
            i += 2;
        }
        cout << res[i] << " " << res[i+1] << " ";
    }
    cout << '$' << endl;
}


Measured memory_bytes: 3608
s = input()
n = []
op = []

def calc(lst,n,op):
  if lst:
    op.append('+')
    p = calc(lst[:-1],n+lst[-1],op)
    if p:
      return p
    op.pop()
    op.append('-')
    n = calc(lst[:-1],n-lst[-1],op)
    if n:
      return n
    op.pop()
  else:
    if n == 7:
      return op
    else:
      return None
  
    

for i in range(3):
  n.append(int(s[3-i]))
op = calc(n,int(s[0]),op)
print('{}{}{}{}{}{}{}=7'.format(s[0],op[0],s[1],op[1],s[2],op[2],s[3]))

Measured memory_bytes: 3064
/*   Author : S7a2a7d   */
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")


using namespace std;

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ll long long
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define mem(arr,x) memset(arr,x,sizeof(arr))

typedef vector<ll> vi;
typedef vector<char> vc;
     
#define mp make_pair
#define ff first
#define ss second
     
const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;  
const int inf = 1e9 + 5;

ll lcm(ll a,ll b)
{
        return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
int max(int a,int b)
{
        if(a<b)
        return b;
        return a;
} 

int main()
{
  fast_io;
  int T=1;
  //cin>>T;
  while(T--)
  {ll n;
    ll x,y;
    cin>>n;
    ll ans=0;
    while(n--)
    {
      cin>>x>>y;
      if(x==y)
        ans++;
      else
      {
        ans=0;
      }
      if(ans==3)
      {
        break;
      }
    }
    if(ans>=3)
      cout<<"Yes";
    else
      cout<<"No";

     
  }
    
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
minus = 0
for j in range(n):
    if a[j] < 0:
        minus += 1
for i in range(n-1):
    if a[i] < 0:
        a[i] = a[i] * -1
        a[i+1] = a[i+1] * -1
if a[n-1] < 0:
    a[n-1] = a[n-1] * -1
if minus % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2*min(a))

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

long long ara[200003],vis[200003],ans[200003];
vector<long long>adj[200003];

void dfs(long long src,long long val)
{

    vis[src]=1; ans[src]=val+ara[src];
    long long sz=adj[src].size();

    for(long long lp=0;lp<sz;lp++)
    {
        long long u=adj[src][lp];

        if(vis[u]!=1)
        {
            dfs(u,ans[src]);
        }


    }



}

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld",&n,&q);
        for(i=1;i<=n-1;i++)
        {
            scanf("%lld %lld",&a,&b);
            adj[a].push_back(b);  adj[b].push_back(a);

        }

        for(i=1;i<=q;i++)
        {
            scanf("%lld %lld",&a,&b); ara[a]=ara[a]+b;

        }

        dfs(1,0);

        for(i=1;i<=n;i++)
        {
            printf("%lld ",ans[i]);
        }




    return 0;
}





Measured memory_bytes: 31704
#include <iostream>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s==u) a-=1;
  if(t==u) b-=1;
  cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 256
D = int(input())
cs = list(map(int, input().split()))
ss = [input().split() for l in range(D)]
ts = [int(input()) for i in range(D)]
ans=0
all_cs=sum(cs)
cs_last=[0]*26

def c0(d):
    mainas=0
    for i in range(26):
        #print(cs[i]*(d-cs_last[i]))
        mainas-=cs[i]*(d-cs_last[i])
    return mainas



for i in range(D):
    cs_last[ts[i]-1]=i+1
    ans+=int(ss[i][ts[i]-1])+c0(i+1)
    
    print(ans)

Measured memory_bytes: 9664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

string S, T, U;
ll A, B;

int main() {
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S) {
        A--;
    } else {
        B--;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
typedef double ld;

vector<ld> p, dp[2];

int main() {
	int n; cin >> n; p.resize(n);
	dp[0].resize(n + 1, 0.0); dp[1].resize(n + 1, 0.0);
	for (auto &x : p) { cin >> x; }
	dp[0][0] = 1.0; for (int i = 1; i <= n; i++) {
		dp[i & 1][0] = dp[(i ^ 1) & 1][0] * (1.0 - p[i - 1]);
		for (int j = 1; j <= n; j++)
			dp[i & 1][j] = p[i - 1] * dp[(i ^ 1) & 1][j - 1] + (1.0 - p[i - 1]) * dp[(i ^ 1) & 1][j];
	}
	int s = (n + 1) >> 1; ld res = 0.0;
	while (s <= n) res += dp[n & 1][s++];
	cout << fixed << setprecision(10) << res << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int a, b, c;
  string s;
  cin >> a >> b >> c;
  if (a == b && a != c)
    cout << "Yes" << endl;
  else if (a == c && a != b)
    cout << "Yes" << endl;
  else if (b == c && a != b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int search(int A[], int n, int key)
{
	int i=0;
	A[n] = key;
	while(A[i] != key){
		i++;
	}
	return i != n;
}


int main(void)
{
	int i, n;
	int A[10000+1];
	int q, key;
	int c=0;
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	
	scanf("%d", &q);
	for(i=0; i<q; i++){
		scanf("%d", &key);
		if(search(A, n, key)) c++;
	}
	printf("%d\n", c);
	
	return 0;
}



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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

long long arr[100002];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    long long x;
    cin >> n >> x;

    long long tot = 0;

    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        tot += max(0LL, arr[i] - x);
        arr[i] = min(x, arr[i]);
    }

    for(int i = 1; i < n; ++i){
        if(arr[i - 1] + arr[i] > x){
            long long dec = arr[i - 1] + arr[i] - x;
            arr[i] -= dec;
            tot += dec;
        }
    }

    cout << tot;

    return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    vec v(N);
    rep(i, N) cin >> v[i];
    int res = 0;
    rep(i, N){
        Rep(j, i+1, N){
            Rep(k, j+1, N){
                if(v[i] == v[j] || v[j] == v[k] || v[k] == v[i]) continue;
                if(abs(v[i] - v[j]) < v[k] && v[k] < v[i] + v[j]) res++;
            }
        }
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7752
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a, b, k;

        a = sc.nextInt();
        b = sc.nextInt();

        if (a > b) {
            int temp = b;
            b = a;
            a = temp;
        }
        for (k = a; k <= b; k++) {
            if (Math.abs(a - k) == Math.abs(b - k)) {
                System.out.println(k);
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main()
{
    vector<int> a;
    int n, q, b, e, k, count;
    
    cin >> n;
    a.resize(n);
    
    // data input
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    
    cin >> q;
    // query processing
    for (int i=0; i<q; ++i){
        cin >> b >> e >> k;
        count = 0;
        for (int j=b; j<e; ++j){
            if(a[j] == k){
                count++;
            }
        }
        cout << count << endl;
    }
}



Measured memory_bytes: 3108
a = int('a', 36)
S = list(input())
T = list(input())

s_index = [[] for i in range(28)]
t_index = [[] for i in range(28)]

for i in range(len(S)):
  s_index[int(S[i], 36) - a].append(i)
  t_index[int(T[i], 36) - a].append(i)

s_index = sorted(s_index)
t_index = sorted(t_index)

if s_index == t_index:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 17256
H,W,A,B=map(int,input().split())
MAX_NUM = 2*10**5 + 1
pr = 10**9+7
fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]
fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % pr
    inv[i] = pr - inv[pr%i] * (pr // i) % pr
    finv[i] = finv[i-1] * inv[i] % pr
def c(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % pr) % pr
a=0
while 1:
    a=(a+c(H-A-1+B,B)*c(A+W-B-1,A))%pr
    A+=1
    B+=1
    if A==H or B==W:
        break
print(a)

Measured memory_bytes: 26904
#include<bits/stdc++.h>
#define MAXN 5005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,p[MAXN];
int fact[MAXN];
int fa[MAXN],cntv[MAXN],cnte[MAXN],r[MAXN],ans;
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
void init(int n)
{
    for(int i=1;i<=n;i++)
    {
        fa[i]=i;
        cntv[i]=1;
        cnte[i]=0;
        r[i]=0;
    }
}
int find(int x)
{
    if(fa[x]==x) return x;
    else return fa[x]=find(fa[x]);
}
void unite(int x,int y)
{
    x=find(x);
    y=find(y);
    if(x==y) {cnte[x]++; return;}
    if(r[x]<r[y]) 
    {
        fa[x]=y;
        cntv[y]+=cntv[x];
        cnte[y]+=cnte[x]+1;
    }
    else
    {
        fa[y]=x;
        cntv[x]+=cntv[y];
        cnte[x]+=cnte[y]+1;
        if(r[x]==r[y]) r[x]++;
    }
}
int dp[MAXN],ndp[MAXN];
vector<int> sz;
int main()
{
    fact[0]=1;
    for(int i=1;i<=5000;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    scanf("%d",&n);
    int k=0;
    for(int i=1;i<=n;i++) 
    {
        scanf("%d",&p[i]);
        if(p[i]==-1) k++;
    }
    ans=1LL*n*pow_mod(n-1,k)%MOD;
    init(n);
    for(int i=1;i<=n;i++) if(p[i]!=-1) unite(i,p[i]);
    for(int i=1;i<=n;i++)
    {
        if(i==find(i))
        {
            if(cntv[i]==cnte[i]) dec(ans,pow_mod(n-1,k));
            else sz.push_back(cntv[i]);
        }
    }
    dp[0]=1;
    for(int i=0;i<(int)sz.size();i++)
    {
        memset(ndp,0,sizeof(ndp));
        for(int j=0;j<=i;j++)
        {
            add(ndp[j],dp[j]);
            add(ndp[j+1],1LL*dp[j]*sz[i]%MOD);
        }
        swap(dp,ndp);
    }
    for(int i=2;i<=(int)sz.size();i++)
    {
        dec(ans,1LL*dp[i]*fact[i-1]%MOD*pow_mod(n-1,k-i)%MOD);
    }
    for(int i=0;i<k;i++)
    {
        dec(ans,1LL*(sz[i]-1)*pow_mod(n-1,k-1)%MOD);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>

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

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  if (N <= 111) {
    ans = 111;
  } else if (N <= 222) {
    ans = 222;
  } else if (N <= 333) {
    ans = 333;
  } else if (N <= 444) {
    ans = 444;
  } else if (N <= 555) {
    ans = 555;
  } else if (N <= 666) {
    ans = 666;
  } else if (N <= 777) {
    ans = 777;
  } else if (N <= 888) {
    ans = 888;
  } else {
    ans = 999;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

inline int GETI(const char& c) { return c - 'a'; }
const char UNDEF = 'A';

class C {
	string S, T;
	char coding[26];
	bool used[26];
public:
	void solve()
	{
		bool flag{ true };
		char s, t;

		for (int i{ 0 }; i < S.size(); i++)
		{
			s = S[i];
			t = T[i];

			if (coding[GETI(s)] == UNDEF)
			{
				if (used[GETI(t)])
				{
					flag = false;
					break;
				}
				coding[GETI(s)] = t;
				used[GETI(t)] = true;
			}
			else
			{
				if (coding[GETI(s)] != t)
				{
					flag = false;
					break;
				}
			}
		}

		if (flag) cout << "Yes" << endl;
		else cout << "No" << endl;


	}
	
	C()
	{
		cin >> S >> T;
		for (int i{ 0 }; i < 26; i++)
		{
			coding[i] = UNDEF;
			used[i] = false;
		}
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ar=array<ull,26>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
int main(){
	string s1,s2;
	ar ht; ht[0]=1;
	rep(i,25) ht[i+1]=ht[i]*10007;
	
	while(cin>>s1>>s2){
		if(s1.size()>s2.size()) swap(s1,s2);
		int n1=s1.size(), n2=s2.size();
		unordered_set<ull> list1;
		vector<ull> p1(1,0),p2(1,0),p3(n1+1),p4(n2+1);
		for(auto c:s1)p1.push_back(ht[c-'a']);
		for(auto c:s2)p2.push_back(ht[c-'a']);
		partial_sum(p1.begin(), p1.end(), p3.begin());
		partial_sum(p2.begin(), p2.end(), p4.begin());
		
		for(int l=n1;l>=1;l--){
			list1.clear();
			ull tmp=p3[l-1];
			range(i,l,n1+1) {
				tmp+=p1[i];
				tmp-=p1[i-l];
				list1.insert(tmp);
			}
			tmp=p4[l-1];
			range(i,l,n2+1){
				tmp+=p2[i];
				tmp-=p2[i-l];
				if(list1.find(tmp) != list1.end()){
					cout<<l<<endl;
					goto end;
				}
			}
		}
		cout<<0<<endl;
		end: ;
	}
	return 0;
}



Measured memory_bytes: 3308
N, M = tuple(map(int, input().split()))
P, S = [], []
for _ in range(M):
    p, s = input().split()
    P.append(int(p))
    S.append(s)

accepted = [False] * N
wrong = [0] * N
AC, WA = 0, 0
for p, s in zip(P, S):
    if s == "WA":
        if not accepted[p-1]:
            wrong[p-1] += 1
    elif s == "AC" and accepted[p-1] is False:
        accepted[p-1] = True
        AC += 1
        WA += wrong[p-1]
print(AC, WA)


Measured memory_bytes: 15304
#include<iostream>
using namespace std;
int main()
{
  int x,y, tmp;


  while(true){
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x < y){
      cout << x << " " << y << endl;
    }else{
      cout << y << " " << x << endl;
    }

  }


  //cout << endl;
}



Measured memory_bytes: 2984
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

set<ll> ss;

void test(int N, int K) {
  vector<int> vec(N*3);
  for (int i=0; i<N*3; i++)
    vec[i] = i + K;

  do{
    do{
      bool ok = true;
      for (int i=0; i<N; i++) {
        ok &= vec[i] + vec[i+N] <= vec[i+N*2];
      }

      if (ok) {
        cerr << " **** " << endl;
        for (int i=0; i<N; i++)
          cerr << vec[i]-K << " " << vec[i+N]-K << " " << vec[i+N+N]-K << endl;
      }

    }while(next_permutation(vec.begin() + N, vec.begin() + N * 2));
  }while(next_permutation(vec.begin(), vec.begin() + N));
}

int main(){
  ll N, K;

  cin >> N >> K;

  //test(N, K);
  //return 0;

  vector<pair<ll,pair<ll,ll> > > ans;


  for (int i=N; i<N*2; i++)
    ss.insert(i);

  ll j = 0;
  for (ll i=2*N; i<3*N; i++, j++) {
    ll t = i - K;

    ll s = j <= N/2 ? N/2-j : N - j + N/2;

    auto it = ss.upper_bound(t - s);

    if (it == ss.begin()) break;
    it--;

    ll u = *it;

    ans.push_back({u, {s, i}});
    debug(ans[ans.size()-1]);

    ss.erase(u);
  }

  if (ans.size() == N) {
    for (auto p : ans) {
      cout << p.first+K << " " << p.second.first+K << " " << p.second.second+K << '\n';
    }
  } else {
    cout << -1 << endl;
  }


  return 0;
}


Measured memory_bytes: 9968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	ll n,dsum=0,disum=0,djsum=0,ic=0,jc=0,iic=-1,icount[100001],jcount[100001];
	cin>>n>>s;
	for(ll i=n-1;i!=-1;i--){
		switch(s[i]){
			case 'J':dsum+=disum;break;
			case 'O':disum+=ic;break;
			case 'I':ic++;
		}
		icount[i]=ic;
	}
	for(ll i=0;i<n;i++){
		if(s[i]=='O')djsum+=jc;
		if(s[i]=='J')jc++;
		jcount[i]=jc;
	}
	for(ll i=1;i<n;i++)iic=max(iic,icount[i]*jcount[i-1]);
	cout<<max(iic,max(disum,djsum))+dsum<<endl;
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
 
int N;
vector<int> coin{1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
vector<int> dp(100001, INT_MAX);
 
int main(void){
    
    cin >> N;
    
    for(auto i : coin) dp[i] = 1;
    dp[0] = 0;
    
    for(int i = 0; i <= N; ++i){
        for(auto c : coin){
            if(i + c <= 100000) dp[i + c] = min(dp[i + c], dp[i] + 1);
        }
    }
    
    cout << dp[N] << endl;
    
    return 0;
    
}

Measured memory_bytes: 640
import sys
import math

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    if math.ceil(N/2)>=K:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
	char s[5];
	rep(i, 4) cin >> s[i];
	sort(s, s+4);
	if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main()
{
    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d,vector<int>(26));

    for (int i = 0; i < 26; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    for (int i = 0; i < d; i++)
    {
        t[i] = i % 26 + 1;
    }
    
    int m = 10000;
    long long ans = 0;
    while(m--){
        vector<int> tt(d);
        for (int i = 0; i < d; i++)
        {
            tt[i] = t[i];
        }
        int dd = m % d,p = (m % 26 + 13) % 26 + 1;
        t[dd] = p;

        long long buf = 0;
        vector<int> last(26,0);
        for (int i = 0; i < d; i++)
        {
            buf += s[i][t[i] - 1];
            last[t[i] - 1] = i + 1;
            for (int j = 0; j < 26; j++)
            {
                buf -= c[j] * (i + 1 - last[j]);
            }
        }

        if(ans < buf)ans = buf;
        else
        {
            for (int i = 0; i < d; i++)
            {
                t[i] = tt[i];
            }
        }
    }
    //cout << ans << endl;
    for (int i = 0; i < d; i++)
    {
        cout << t[i] << endl;
    }
}


Measured memory_bytes: 3660
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    string s, t; cin >> s >> t;

    string x = "";
    for(int i=0; i<N; i++) {
        x += s[i];
        x += t[i];
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
using System.Linq;
using static System.Console;

public static class Program
{
    public static void Main()
    {
        var line = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var l = line[0];
        var r = line[1];
        var d = line[2];
        int count = 0;
        for(int i = l; i <= r; ++i)
        {
            if (i % d == 0) ++count;
        }
        WriteLine(count);
    }
}

Measured memory_bytes: 28148
#include<stdio.h>
int solve(int N){
    if(N/100 == 7)
        return 1;
    N %= 100;
    if(N/10 == 7)
        return 1;
    N %= 10;
    if(N == 7)
        return 1;
    else 
        return 0;
}
int main(){
    int N;
    scanf("%d",&N);
    if(solve(N))
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 1732