akhauriyash/Code-Regression huggingface dataset:
import sys
h, w, a, b = map(int, input().split())
x, y = -1, -1
for i in range(h+1):
    for j in range(w+1):
        if a*i + (w-a)*(h-i) == b*j + (h-b)*(w-j):
            x, y = i, j
            break
    if not(x == y == -1): break
if x == y == -1:
    print("No")
    sys.exit()
numh = [0]*h
numw = [0]*w
for i in range(h):
    for j in range(w):
        if j < y:
            if numw[j] < b and ((i < x and numh[i] < a) or (i >= x and numh[i] < w-a)):
                print("0", end="")
                numh[i] += 1
                numw[j] += 1
            else: print("1", end="")
        else:
            if numw[j] < h-b and ((i < x and numh[i] < a) or (i >= x and numh[i] < w-a)):
                print("0", end="")
                numh[i] += 1
                numw[j] += 1
            else: print("1", end="")
    print("")

Measured memory_bytes: 5488
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
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 All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int X, Y;
    cin >> X >> Y;
    if(Y - 2 * X >= 0 && (Y - 2 * X) % 2 == 0 && 4 * X - Y >= 0 &&
       (4 * X - Y) % 2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define fi first
#define se second
#define mp make_pair
int main() {


ll n;
cin>>n;
ll a[n],b[n];
for(ll i=0;i<n;i++)
{
  cin>>a[i];
}
for(ll j=0;j<n;j++)
{
  cin>>b[j];
}
ll sum=0;
for(ll i=0;i<n;i++)
{
  if(a[i]>b[i])
  {
    sum+=a[i]-b[i];
  }
}
cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
   string s,tmp;
   ll k,one=0,second=0,key=0,key2 = 0;
   cin >> s >> k;
    tmp =s;
    ll size = s.size();
    if(size == 1){
        cout << k/2 << endl;
        return 0;
    }
    
    for(ll i=0; i<size-1; ++i){
        if(s[i] == s[i+1]){
            if(i==size-3){key = 1;}
            ++one;
            ++i;
        }
    }
    tmp[0] = tmp[0] + 1;
    for(ll i=1; i< size-1; ++i){
        if(tmp[i] == tmp[i+1]){
            if(i==size-2){key2 = 1;}
            ++second;
            ++i;
        }
    }
    //cout << "one " << one << "\n" << second << "\n";
    /*
    ll ans = 0;
    if(s[0] == s[size-1]&&s[0]==s[1]){
        ans=one*k;
    }else if(s[0]==s[size-1] && s[0] != s[1]){
        ans = one + (one+1)*(k-1);
    }else{
        ans = one*k;
    }*/
    /*if(k==3)
    if(s[0] == s[size-1] && s[size -2] != s[size-1] && size%2 != 0){
        cout << one + (second+1) *(k-1) <<endl;
        return 0; 
    }*/
    if(s[0] == s[size -1] && key == 1 && key2 ==0 ){
        cout << one + (second +1) *(k-1); 
        return 0;
    }
    if(s[0] == s[size -1] && key == 1 && key2 ==1){
        if(k%2 == 0){
            cout << one + (one+second+1)*((k-1)/2) + second+1 << endl;
        }else{
            cout << one +(one + second +1)*(k/2) << endl;
        }
        return 0;
    }
    cout << one*k << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int n;
	cin >> n;
	for(int k = 1; k <= n; k++){
		if((2*n)%k != 0) continue;
		if(k == (2*n)/k - 1){
			cout << "Yes" << endl;
			// TODO 構築
			// 集合の数は k + 1
			k += 1;
			vector<vector<int>> ans(100010);
			int mother = 0;
			int child = 1;
			
			for(int i = 1; i <= n; i++){
				ans[mother].push_back(i);
				ans[child].push_back(i);
				if(ans[mother].size() == k - 1){
					mother ++;
					child = mother + 1;
				} else {
					child ++;
				}
			}
			cout << k << endl;
			rep(i,k){
				cout << k - 1 << " ";
				for(auto x:ans[i]){
					cout << x <<" ";
				}
				cout << endl;
			}
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

#include<complex>
typedef complex<double> Point;

double cross(Point a, Point b){
  return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
  b -= a;
  c -= a;
  if(cross(b, c) > EPS) return +1;
  if(cross(b, c) < -EPS) return -1;
  return 0;
}

int main(){
  Point a, b, c, d;
  while(cin >> a.real() >> a.imag() >> b.real() >> b.imag() >> c.real() >> c.imag() >> d.real() >> d.imag()){
    int A = ccw(a, b, d);
    int B = ccw(b, c, d);
    int C = ccw(c, a, d);
    if(A == B && B == C && A != 0){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1220
import sys

def main():
    N, Z, W = map(int, input().split())
    A = list(map(int, input().split()))

    if len(A) == 1:
        ans = abs(A[0] - W)
    else:
        ans = max(abs(A[-1]-W), abs(A[-2]-A[-1]))

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 38640
#include<stdio.h>
int main()
{
  long long n,a,x,mn,mx,s;
  s=0;
  mn=1000000;
  mx=-1000000;
  scanf("%lld",&n);
  for(x=0;x<n;x++){
    scanf("%lld",&a);
    s=s+a;
    if(mn>a){mn=a;}
    if(mx<a){mx=a;}
  }
  printf("%lld %lld %lld\n",mn,mx,s);
  return 0;
}


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

int main() {
  string S;
  cin >> S;

  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0 &&
      S.substr(0, i / 2) == S.substr(i / 2, i / 2)) {
      ans = i;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int a, b; cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;

ll A, B;
ll cnt[3];

int main()
{
  std::cin >> A >> B;
  --A; --B;
  ++cnt[A]; ++cnt[B];

  rep( i, 3 ) if( !cnt[i] )
    std::cout << i+1 << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  ll ans = INF;
  for (ll i = 1; i <= n / 2 + 1;i++){
    ll A = i;
    ll B = n - i;
    ll sum = 0;
    string a=to_string(A);
    string b=to_string(B);
    rep(j,sz(a)){
      sum += a[j] - '0';
    }
    rep(j,sz(b)){
      sum += b[j] - '0';
    }
    chmin(ans, sum);
  }
  print(ans);
}

Measured memory_bytes: 3680
#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() {
    const int max = 10000000;
    int n, m, x, ans = max;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n), alg(m);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) { cin >> a[i][j]; }
    }

    for(int bit = 1; bit < (1 << n); bit++) {
        int money = 0;
        vector<int> alg(m);
        rep(i, n) {
            if(bit & (1 << i)) {
                rep(j, m) alg[j] += a[i][j];
                money += c[i];
            }
        }
        bool flag = true;
        rep(i, m) {
            if(alg[i] < x) {
                flag = false;
                break;
            }
        }
        if(flag) {
            ans = min(ans, money);
        }
    }
    if(ans == max) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
import math

line = input().split(" ")

eight_tax = int(line[0])
ten_tax = int(line[1])

eight_side_price = math.ceil(eight_tax / 0.08)
ten_side_price = math.ceil(ten_tax / 0.1)

while(1):
    break_flg = 0
    for i in range(int(math.fabs(eight_side_price - ten_side_price)) + 1):
        target = eight_side_price if eight_side_price < ten_side_price else ten_side_price
        num = i + target
        if math.floor(num * 0.08) == eight_tax and math.floor(num * 0.1) == ten_tax:
            print(num)
            break_flg = 1

    if break_flg == 0:
        print("-1")
    break

Measured memory_bytes: 3064
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    set<ll> s{A, B, C};
    YES(s.size() == 2);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
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 Per(i,sta,n) for(int i=n-1;i>=sta;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;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

ll a,c;
string b;

void solve(){
    cin >> a;
    cin >> b;
    rep(i,b.length()){
        if(b[i]=='.') continue;
        c+=b[i]-'0';
        c*=10;
    }
    c/=10;
    //cout << c/10 << endl;
    cout << a*c/100ll << endl;
}

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

Measured memory_bytes: 3648
#include<iostream>
#include<queue>

using namespace std;

int main() 
{
    int N,M;
    cin>>N>>M;

    priority_queue<int>L;
    priority_queue<int,vector<int>,greater<int>>R;

    for (size_t i = 0; i < M; i++)
    {
        int l,r;
        cin>>l>>r;
        L.push(l);
        R.push(r);
    }
    
    int ans=0;
    for (size_t i = 1; i < N+1; i++)
    {
        if(i>=L.top()&&i<=R.top())
        {
            ++ans;
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

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

int main(){
    std::string s;
    std::cin >> s;

    int flag = 0;

    if(s[0] == s[1])
        flag++;
    if(s[0] == s[2])   
        flag++;
    if(s[0] == s[3])
        flag++;
    if(s[1] == s[2])
        flag++;
    if(s[1] == s[3])
        flag++;
    if(s[2] == s[3])
        flag++;

    
    if(flag == 2){
        std::cout << "Yes" << std::endl;
    }else
    {
        std::cout << "No" << std::endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;

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

    int array_length = scan.nextInt();

    int[] array =new int[array_length];
    for (int i = 0; i < array_length; i++) {
      array[i] = scan.nextInt();
    }

    printArray(array);

    InsertionSort(array_length, array);
  }

  public static void printArray(int array[]) {
  	for (int i = 0; i < array.length - 1; i++) {
  	    System.out.print(array[i] + " ");
  	}
  	System.out.println(array[array.length-1]);
  }

  public static void InsertionSort(int n, int array[]){
    for(int i = 1; i < n; i++){
      int key = array[i];

      int j = i - 1;
      while(j >= 0 && array[j] > key){
        array[j+1] = array[j];
        j--;
        array[j+1] = key;
      }
      printArray(array);
    }


  }
}


Measured memory_bytes: 32492
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int S, h, m, s, x;
    scanf("%d",&S);
    h = S / 3600;
    x = S - h * 3600;
    m = x / 60;
    s = x % 60;
    printf("%d:%d:%d\n",h, m, s);
    return 0;
    
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    long long i,j=0;
    long long k=0;
    cin>>N;
    vector<int> vec(3*N);
    long long countA=0;
    for(i=0;i<3*N;i++ ){
    cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    i=3*N-1;
    while(k<N){
    if(j%2!=0){
    countA+=vec.at(i);
    k++;}
    i--;
    j++;}
    cout<<countA<<endl;
    }




Measured memory_bytes: 1408
#include <iostream>
#include <map>
#include <utility>

using namespace std;

long long int GCD(long long int x, long long int y) {
    if(x<y) swap(x, y);
    if(y==0) return x;
    return GCD(y, x%y);
}

int main() {
    long long int K;
    cin >> K;
    map<pair<int, int>, long long int> mp;
    for(long long int i=1; i<=K; i++) {
        for(long long j=i; j<=K; j++) {
            mp[make_pair(i, j)] = GCD(i, j);
            if(i==j) continue;
            mp[make_pair(j, i)] = mp[make_pair(i, j)];
        }
    }

    long long int ans=0;
    for(long long int i=1; i<=K; i++) {
        for(long long int j=i; j<=K; j++) {
            long long int ij=mp[make_pair(i, j)];
            for(long long int k=j; k<=K; k++) {
                if(i==j && j==k) {
                    ans += mp[make_pair(ij, k)];
                } else if(i==j || j==k) {
                    ans += mp[make_pair(ij, k)]*3;
                } else {
                    ans += mp[make_pair(ij, k)]*6;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
    
}

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

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

    int h, w;

    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    pair<int, int> dirs[4] = {
            make_pair(0,  1),
            make_pair(1,  0),
            make_pair(0,  -1),
            make_pair(-1,  0)
    };
    // pair<int, int> p;
    int x, y;
    // bool success = false;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') {
                bool clear = false;
                for (const auto &dir : dirs) {
                    y = i + dir.first;
                    x = j + dir.second;
                    if (0 <= y && y < h && 0 <= x && x < w && s[y][x] == '#') {
                        clear = true;
                        break;
                    }
                }
                if (!clear) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  //intput
  int iti[5];
  int k;
  for (int i=0; i<5; i++){
    cin >> iti[i];
  }
  cin >> k;

  // solve
  int idx = 0;
  for (int i=0; i<5; i++){
    for (int j=0; j<i; j++){
      if (iti[i] - iti[j] > k){
        idx++;
      }
    }
  }
  string ans;
  if(idx == 0){
    ans = "Yay!";
  }else{
    ans = ":(";
  }

  //output
  cout << ans << endl;

  return 0;
}


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

int mypow(int n) {
    int ret = 1;
    for (int i = 0; i < n; i++) {
        ret *= 10;
    }

    return ret;
}
int main () {
 int N, M;
    cin >> N >> M;

    map<int, int> order;
    bool b = false;
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
if(N < s) {
            b = true;
        }
        auto ite = order.find(s);
        if (ite != order.cend() && ite->second != c) {
            b = true;
        } else if (s == 1 && c == 0 && N != 1) {
            b = true;
        } else {
            order.insert(pair<int, int>(s,c));        
        }
        
    }

    if (b) {
        cout << "-1" << endl;
        return 0;
    }

    int ans = 0;
    auto ite = order.cbegin();    
    while(ite != order.cend())  {
        ans += ite->second * mypow(N - ite->first);
        ite++;
    }

    int min = (N == 1) ? 0 : mypow(N - 1) ;
    if (ans < min) ans += min;
    cout << ans << endl;

    return 0;
}



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

 int g[15][15];

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

    string s;
    cin >> s;
    if(s=="SUN") cout << 7 << endl;
    if(s=="MON") cout << 6 << endl;
    if(s=="TUE") cout << 5 << endl;
    if(s=="WED") cout << 4 << endl;
    if(s=="THU") cout << 3 << endl;
    if(s=="FRI") cout << 2 << endl;
    if(s=="SAT") cout << 1 << endl;

    

    

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;

double btc2jpy(double x){
	return x*380000.0;
}

int main()
{
	int n;
	double total = 0;
	cin>>n;
	for(int i = 0; i < n;i++){
		double x;
		string str;
		cin>>x>>str;
		if(str == "JPY"){
			total += x;
		}else{
			total += btc2jpy(x);
		}
	}
	printf("%0.5lf",total);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int MOD = 998244353;
long long jc[N];
long long qpow(long long x, long long k) {
    long long r = 1;
    while(k) {
        if(k & 1) r = r * x % MOD;
        k >>= 1;
        x = x * x % MOD;
    }
    return r;
}
long long inv(long long x) {
    return qpow(x, MOD - 2);
}
long long C(long long x, long long y) {
    return jc[x] * inv(jc[y]) % MOD * inv(jc[x - y]) % MOD;
}
int main() {
    jc[0] = jc[1] = 1;
    for(int i = 2; i < N; i++) {
        jc[i] = jc[i - 1] * i % MOD;
    }
    long long n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    for(long long i = 0; i <= n; i++) {
        if((k - a * i) % b == 0) {
            long long x = i, y = (k - a * i) / b;
            if(x <= n && y <= n && y >= 0) ans = (ans + C(n, x) * C(n, y)) % MOD;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
char a[12][13];
void func(int y,int x){
	int i,xx,yy;
	a[y][x]='0';
	for(i=0;i<4;i++){
		xx=x+dx[i]; yy=y+dy[i];
		if(x>=0&&y>=0&&x<12&&y<12&&a[yy][xx]=='1') func(yy,xx);
	}
}
int main(void){
	int i,j,cnt;
	while(scanf("%s",&a[0])!=EOF)	{
		for(i=1;i<12;i++) scanf("%s",a[i]);
		cnt=0;
		for(i=0;i<12;i++){
			for(j=0;j<12;j++){
				if(a[i][j]=='1'){
					cnt++;
					func(i,j);
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 2576
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int a[101][101], b[101][101];
    long long c[101][101], s;
    int i, j, k;
    int n, m, l;
 
    scanf("%d%d%d", &n, &m, &l);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
    }
 
    for (i = 0; i < n; i++) {
        for (j = 0; j < l; j++) {
            s = 0;
            for (k = 0; k < m; k++) {
                s += a[i][k] * b[k][j];
            }
            c[i][j] = s;
        }
    }
 
    for (i = 0; i < n; i++) {
        printf("%lld", c[i][0]);
        for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
        putchar('\n');
    }
    return 0;
}


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


int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if (b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
hhh = list(map(int, input().split()))
nice = [1] * n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ha = hhh[a]
    hb = hhh[b]
    if ha <= hb:
        nice[a] = False
    if ha >= hb:
        nice[b] = False
print(sum(nice))


Measured memory_bytes: 20108
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
import copy
def divisor(n): #約数
    f=[]
    d=[1]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    for i in range(len(f)):
        t=[]
        for j in range(1,f[i][1]+1):
            t.append(f[i][0]**j)
        for j in range(len(d)):
            for k in range(len(t)):
                d.append(d[j]*t[k])
    return sorted(d)
n=I()
A=IL()
Ans=copy.deepcopy(A)
AA=[0]*n
AAA=[0]*n
last=-1
first=n
ans=0
c=True
while first>0:
    last=first
    first=first//2
    for i in range(first,last):
        if A[i]==1:
            if AA[i]==1:
                c=False
                break
            AA[i]=1
            L=divisor(i+1)
            for l in L:
                if A[l-1]==0:
                    A[l-1]=1
                else:
                    A[l-1]=0
                    
                if AAA[l-1]==0:
                    AAA[l-1]=1
                else:
                    AAA[l-1]=0   
                

if AAA!=Ans or not c:
    print(-1)
    print(A)
else:
    print(sum(AA))
    for i in range(n):
        if AA[i]==1:
            print(i+1,end=" ")
    print()

Measured memory_bytes: 78672
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define int long int
#define hell (int)(1e9+7)

using namespace std;

void solve()
{
    bitset <4000005> b(0);
    b[0]=1;
    int n;
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        sum+=x;
        b|=b<<x;
    }
    for(int i=0;i<=sum;i++){
        if(b[i]&&i>=(sum+1)/2){
            cout<<i;
            break;
        }
    }
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}
/*
xzu
dfw
eor
nat
jye

*/


Measured memory_bytes: 1792
# Contest No.: ABC171
# Problem No.: A
# Solver:      JEMINI
# Date:        20200621

import sys
import heapq

def main():
    n = input()
    if n in "abcdefghijklmnopqrstuvwxyz":
        print("a")
    else:
        print("A")
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 62080
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; ++i) {
        if (i % d == 0) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int MAX_T = 70;
const int MAX_P = 20;
int T, P, R;
int tID, pID, ti;
string mes;
int wa[MAX_T][MAX_P];

struct data{int a, p, id; };

inline bool operator < (const data& x, const data& y)
{
  return x.a!=y.a ? x.a<y.a : x.p!=y.p ? x.p>y.p : x.id > y.id;
}

inline bool operator > (const data& x, const data& y)
{
  return !(x < y);
}

int main()
{
  while(cin >> T >> P >> R, T){
    vector<data> g(T, (data){0, 0, 0});
    rep(i, MAX_T) rep(j, MAX_P) wa[i][j] = 0;
    rep(i, T) g[i].id = i;

    rep(i, R){
      cin >> tID >> pID >> ti >> mes;
      tID -= 1;  pID -= 1;
      if(mes == "CORRECT"){
        g[tID].a += 1;
        g[tID].p += wa[tID][pID] * 1200 + ti;
      }
      else wa[tID][pID] += 1;
    }
    sort(ALL(g), greater<data>());
    vrep(v, g) cout << v->id + 1 << ' ' << v->a << ' ' << v->p << endl;
  }

  return 0;
}

Measured memory_bytes: 1240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            for(int x = 1; x <= n; ++x)
            {
                if (x % 3 == 0 || x.ToString().Contains("3"))
                {
                    Console.Write(" {0}", x);
                }
            }

            Console.WriteLine();

        }
    }
}

Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>

using namespace std;

int main(){
  int i,j,k,n,m;
  cin >> n;
  int v[n];
  int m1[100006]={},m2[100006]={};
  int m1m=0,m2m=0;
  for(i=0;i<n;i++){
    cin >> v[i];
    if(i%2==0)m1[v[i]]++;
    else m2[v[i]]++;
  }
  for(i=0;i<100001;i++){
    if(m1[m1m]<m1[i])m1m=i;
    if(m2[m2m]<m2[i])m2m=i;
  }
  sort(m1,m1+100002);
  reverse(m1,m1+100002);
  sort(m2,m2+100002);
  reverse(m2,m2+100002);
  if(m1m!=m2m){
    cout << n-m1[0]-m2[0] << endl;
  }else{
    cout << n-m1[0]-max(m1[1],m2[1]) << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
  int L[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << L[K - 1] << endl;
   return 0;
}

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

constexpr int MAX = 200010;
int n;
int x[MAX], y[MAX], u[MAX];
int ans = 1e9;

map<int, vector<int>> a, b;

void f() {
	for(auto& [_, v] : a) {
		v.clear();
	}
	for(auto& [_, v] : b) {
		v.clear();
	}
	for(int i = 0; i < n; ++i) {
		if(u[i] == 0) {
			b[x[i]].push_back(y[i]);
		}
		if(u[i] == 2) {
			a[x[i]].push_back(y[i]);
		}
	}
	for(auto& [_, v] : a) {
		sort(v.begin(), v.end());
	}
	for(auto& [x, v] : b) {
		for(int y : v) {
			auto itr = lower_bound(a[x].begin(), a[x].end(), y);
			if(itr == a[x].end()) continue;
			ans = min(ans, (*itr - y) * 10 / 2);
		}
	}
}

void g() {
	for(auto& [_, v] : a) {
		v.clear();
	}
	for(auto& [_, v] : b) {
		v.clear();
	}
	for(int i = 0; i < n; ++i) {
		if(u[i] == 0) {
			a[x[i] + y[i]].push_back(x[i]);
		}
		if(u[i] == 3) {
			b[x[i] + y[i]].push_back(x[i]);
		}
	}
	for(auto& [_, v] : a) {
		sort(v.begin(), v.end());
	}
	for(auto& [x, v] : b) {
		for(int y : v) {
			auto itr = upper_bound(a[x].begin(), a[x].end(), y);
			if(itr == a[x].end()) continue;
			ans = min(ans, (*itr - y) * 10);
		}
	}
}

int main() {
	cin >> n;
	constexpr char c[] = {'U', 'L', 'D', 'R'};
	for(int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
		char cc; cin >> cc;
		for(int j = 0; j < 4; ++j) {
			if(c[j] == cc) {
				u[i] = j;
			}
		}
	}
	for(int i = 0; i < 4; ++i) {
		f();
		g();
		for(int j = 0; j < n; ++j) {
			u[j] = (u[j] + 1) % 4;
			swap(x[j], y[j]);
			x[j] = -x[j];
		}
	}
	if(ans == 1e9) {
		cout << "SAFE" << '\n';
		return 0;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 86728
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;

int n;

int tab[nax];

ll wyn;

set <int> setel;

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		scanf("%d", &tab[i]);
	tab[0]=-1;
	for (int i=n; i; i--)
	{
		if (tab[i]>tab[i-1]+1)
		{
			printf("-1\n");
			return 0;
		}
		setel.insert(tab[i]-i);
		setel.erase(-i);
		wyn+=setel.size();
	}
	printf("%lld\n", wyn);
	return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 50005, M = 100005;

int n, m, T, x[M], y[M], ans[M];
std::bitset<N> S[N], B;
bool A[N];
int to[N], sz[N];

int main() {
	read(n), read(m), read(T);
	for (int i = 1; i <= m; ++i) {
		read(x[i]), read(y[i]);
	}
	if (T == 1) {
		for (int i = 1; i <= n; ++i) {
			S[i][i] = 1;
		}
		for (int i = m; i; --i) {
			S[x[i]] = S[y[i]] = S[x[i]] | S[y[i]];
		}
		B = S[1];
		for (int i = 2; i <= n; ++i) {
			B &= S[i];
		}
		if (B.count() == 0) {
			print(-1);
			return 0;
		}
		int u = B._Find_first();
		A[u] = 1;
		for (int i = m; i; --i) {
			ans[i] = A[y[i]];
			A[x[i]] = A[y[i]] = A[x[i]] | A[y[i]];
		}
		for (int i = 1; i <= m; ++i) {
			putchar(ans[i] ? 'v' : '^');
		}
		putchar('\n');
	} else {
		if (n <= 2 && m) {
			print(-1);
			return 0;
		}
		for (int i = 1; i <= n; ++i) {
			to[i] = i, sz[i] = 1;
		}
		for (int i = m; i; --i) {
			int u = x[i], v = y[i];
			ans[i] = 0;
			if (sz[to[u]] == n - 1) {
				ans[i] ^= 1;
				std::swap(u, v);
			}
			--sz[to[v]];
			to[v] = to[u];
			++sz[to[v]];
		}
		for (int i = 1; i <= m; ++i) {
			putchar(ans[i] ? 'v' : '^');
		}
		putchar('\n');
	}
}


Measured memory_bytes: 311588
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;  //これで"std::cout"が"cout"と書ける

//MACRO
typedef long long ll;                  //64bit以上を表現可能な型
#define INF 100000000                  //ほぼ無限
#define itn int                        //タイポ対策
#define ALL(x) (x).begin(), (x).end()  //sort(all(x))などとする
#define SZ(x) ((int)(x).size())        //size()簡略化
//repetition
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define repR(i, n) for (int i = n; i >= 0; i--)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;
template <class T>
bool chMAX(T &a, const T &b) {  //aよりbが大きければaに代入(参照渡し)
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chMIN(T &a, const T &b) {  //aよりbが小さければaに代入//参照渡し
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int ctoi(const char c) {  //CtoI(int) charを渡すとintに変換する、数字以外だと-1を返す
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}

template <typename T>
std::string to_string(const T &n) {
    std::ostringstream stm;
    stm << n;
    return stm.str();
}

template <typename List>
/*
好きな区切り文字でsplit
引数:対象の文字列,区切り文字,結果を格納する可変長配列
*/
void split(const std::string &s, const std::string &delim, List &result) {
    result.clear();

    using string = std::string;
    string::size_type pos = 0;

    while (pos != string::npos) {
        string::size_type p = s.find(delim, pos);

        if (p == string::npos) {
            result.push_back(s.substr(pos));
            break;
        } else {
            result.push_back(s.substr(pos, p - pos));
        }

        pos = p + delim.size();
    }
}

/*エラトステネスのふるい
vector<bool> num(100000 + 2, true);
num[0] = false;
num[1] = false;

FOR(i, 2, SZ(num)) {
    if (num[i]) {
        for (int j = 2; (i * j) <= SZ(num); j++) {
            num[i * j] = false;
        }
    }
}
*/

//
//
//

main() {
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if (d2 == 1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::string S;

int main()
{
  std::cin >> N >> S;

  ll ans = 0;

  rep( i, N-2 ) if( S.substr(i,3) == "ABC" ) {
    ++ans;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

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

    int H[N];
    for(int i=0; i<N; i++){
        cin >> H[i];
    }

    for(int i=N-1; i>=1; i--){
        if(H[i-1] > H[i]){
            H[i-1]--;
        }
    }

    int fl=0;
    for(int i=0; i<N-1; i++){
        if(H[i] > H[i+1]){
            fl=1;
            break;
        }
    }

    if(fl){
        cout << "No";
    }else{
        cout << "Yes";
    }

    return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int solve(){}
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int n,k,c;cin>>n>>k>>c;
	string s;cin>>s;	
	v vec;
	f(i,n)
	{
		if(s[i]!='x')vec.pb(i);
	}
	v taken;
	int prev=-n-1;
	int ans=0;
	for(auto it:vec)
	{
		if(it-prev-1 >=c)
		{
			taken.pb(it);
			prev=it;
			ans++;
		}
	}
	if(ans > k)
	{
		return 0;
	}
	v suf(n,0);
	v aa;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]!='x')
		{
			auto it1=upper_bound(all(vec),i+c);
			suf[i]=1;
			if(it1!=vec.end())
			{
				suf[i]+=suf[*it1];
			}
			auto it=lower_bound(all(taken),i);
			if(it!=taken.end() && *it==i)
			{
				auto it1=upper_bound(all(vec),i);
					if(it1== vec.end() || suf[i]!=suf[*it1])
					{
						aa.pb(i+1);
						continue;
					}
			}
		}

	}
	reverse(all(aa));
	for(auto it:aa)cout<<it<<endl;
	return 0;
}

Measured memory_bytes: 8200
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int ans = 0;
        int tmp = 0;
        int h1 = Integer.parseInt(sc.next());
        int h2 = 0;
        for(int i = 1;i<n;i++){
            h2 = Integer.parseInt(sc.next());
            if(h1 >= h2){
                tmp += 1;
                if(i == n -1){
                    ans = Math.max(tmp,ans);
                }
            }else{
                ans = Math.max(tmp,ans);
                tmp = 0;
            }
            h1 = h2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 48576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
 int dp[n];
  dp[0]=abs(a[1]-a[0]);
  if(n>2){
  dp[1]=min((abs(a[0]-a[2])),(dp[0]+abs(a[1]-a[2])));
  //dp[2]=min(dp[1]+abs(a[2]-a[1]),dp[0]+abs(a[0]-a[2]));
  for(int i=2;i<n;i++){
    dp[i]=min((dp[i-1]+abs(a[i+1]-a[i])),(dp[i-2]+abs(a[i+1]-a[i-1])));}
    cout<<dp[n-2];}
  else cout<<dp[0];
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

int64 counter[2019];

int powMod(int a, int n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        int b = powMod(a, n / 2);
        return (b * b) % 2019;
    }
    return (a * powMod(a, n - 1)) % 2019;
}

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

    string S;
    cin >> S;

    int mod = 0;
    int64 ans = 0;
    counter[0]++;
    for (int i = (int)S.size() - 1; i >= 0; i--) {
        (mod += (S[i] - '0') * powMod(10, (int)S.size() - 1 - i)) %= 2019;
        // int x = (2019 - mod) % 2019;
        ans += counter[mod];
        counter[mod]++;

        // cerr << "i: " << i + 1 << " mod: " << mod << " " << counter[x] << endl;

    }
    cout << ans << endl;

    return 0;
}



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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, a, b) for(int i = a; i < b; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // vvvi V (50, vvi(50, vi(2500)));

    int N, K, d, a;
    cin >> N >> K;
    vector<int> A(N+1);

    rep(i, 0, K){
        cin >> d;
        rep(j, 0, d){
            cin >> a;
            A[a]++;
        }
    }

    int ans = 0;
    rep(i, 1, N+1){
        if(A[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648