akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    Fast;
    int t,n,m,i,j,k,x=0,y=0,z;
    cin>>n>>m;
    map<int,int>mp1;
    vector<int>v[1000];
    int a[1000]= {100000,100000,100000,100000,100000};
    for(int i=0; i<m; i++)
    {
        int l,r;
        cin>>l>>r;
        v[l].push_back(r);

    }
    int ok1=0;
    for(int i=1; i<=n; i++)
    {
        int ok=0;
        if(v[i].size()>0)
        {
            sort(v[i].begin(),v[i].end());
            for(int j=0; j<v[i].size()-1; j++)
            {
                if(v[i][j]!=v[i][j+1])
                {
                    ok=1;
                }
            }
            if(ok==0)
            {
                a[i]=v[i][0];
            }
        }
        if(ok==1)
        {
            ok1=1;
        }
    }
    if(n==1 && ok1==1){
        cout<<-1<<endl;
        return 0;
    }
    if(n==1 && ok1==0){
            if(a[1]==100000){
                cout<<0<<endl;
                return 0;
            }
        cout<<a[1]<<endl;
        return 0;
    }
    if(ok1==1)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1; i<=n; i++)
    {
        if(i==1 && n!=1)
        {
            if(a[i]==0)
            {
                cout<<-1<<endl;
                return 0;
            }
        }
        if(a[i]==100000)
        {
            a[i]=0;
        }
    }
    if(a[1]==0)
    {
        a[1]=1;
    }
    for(int i=1; i<=n; i++)
    {
        cout<<a[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
//解説丸写しです これDの難易度じゃねえ
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
const ll inf=ll(1e+18)+1;
int main(void){
    int n;ll k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll left=-inf,right=inf;
    while(right-left>1){
        ll x=(left+right)/2;
        bool ok=[&]{
            ll tot=0;
            rep(i,n){
                if(a[i]<0){
                    int l=-1,r=n;
                    while(r-l>1){
                        int c=(l+r)/2;
                        if(a[c]*a[i]<x) r=c; else l=c;
                    }
                    tot+= n-r;
                }else{
                    int l=-1, r=n;
                    while(r-l>1){
                        int c=(r+l)/2;
                        if(a[c]*a[i]<x) l=c; else r=c;
                    }
                    tot+=r;
                }
                if(a[i]*a[i]<x)tot--;
            }
            tot/=2;
            return tot<k;
        }();
        if(ok)left=x; else right=x;
    }
    cout<<left<<endl;
    return 0;
}

Measured memory_bytes: 1792
# coding:utf-8

import sys
from collections import Counter, deque

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


N = I()
A = [I() for _ in range(N)]

A.sort()
B = deque()

state = 1
for i in range(N // 2):
    if state:
        B.append(A[i])
        B.appendleft(A[-(i + 1)])
    else:
        B.append(A[-(i + 1)])
        B.appendleft(A[i])
    state ^= 1
if N % 2:
    C = deque(B)
    B.append(A[N // 2])
    C.appendleft(A[N // 2])
else:
    C = A[:]

ans1 = 0
ans2 = 0
for i in range(N - 1):
    ans1 += abs(B[i] - B[i + 1])
    ans2 += abs(C[i] - C[i + 1])

print(max(ans1, ans2))


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

typedef unsigned long long int lli;

int main()
{
    int x, y;
    cin >> x >> y;

    if(y % 2 == 1)
    {
        cout << "No";
    }
    else
    {
        if( y <= 4*x && y >= 2*x)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3;
    lli i,j,k,a,b,c,d,n,m,sum=0,ans=0,temp,t;
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c;
    
    
    return 0;
}





















/* UJJWAL KESHRI */

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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> perm(N);
    {
        vector<pair<long, long>> p(N);
        for(auto& i : p)cin >> i.first >> i.second;
        sort(p.begin(), p.end());
        iota(perm.begin(), perm.end(), 0UL);
        sort(perm.begin(), perm.end(), [&p](auto i, auto j){return p[i].second < p[j].second;});
    }

    constexpr unsigned long MOD = 998244353;
    vector<unsigned long> binary(N + 1);
    binary[0] = 1;
    for(unsigned long i = 0; i < N; ++i)binary[i + 1] = binary[i] * 2 - (binary[i] > 499122176) * MOD;

    vector<unsigned long> fenwick_tree(N);
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long r = i;
        unsigned long ret{fenwick_tree[i]};
        while(i &= i + 1)ret += fenwick_tree[--i];
        i = r;
        while(i < N){
            ++fenwick_tree[i];
            i |= i + 1;
        }
        return ret;
    };

    vector<unsigned long> coef(N + 1);
    for(unsigned long i = 0; i < N; ++i){
        auto q = que(perm[i]);
        ++coef[q];
        ++coef[i - q];
        ++coef[perm[i] - q];
        ++coef[N - i - perm[i] + q - 1];
    }

    cout << inner_product(binary.begin(), binary.end(), coef.begin(), (N + MOD - 4) * (binary[N] - 1) % MOD, plus<>(), [&MOD](auto a, auto b){return a * b % MOD;}) % MOD << endl;
    return 0;
}

Measured memory_bytes: 6488
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, C;
    cin >> N >> C;
    pair<ll, ll> sushi[N + 2] = {};
    for(ll i = 0; i < N; i++) cin >> sushi[i + 1].first >> sushi[i + 1].second;
    ll mae = 0;
    ll po[N + 1] = {}, yo[N + 1] = {};
    for(ll i = 0; i < N; i++){
        po[i + 1] = po[i] + sushi[i + 1].second - (sushi[i + 1].first - mae);
        mae = sushi[i + 1].first;
    }
    mae = C;
    for(ll i = 0; i < N; i++){
        yo[i + 1] = yo[i] + sushi[N - i].second - (mae - sushi[N - i].first);
        mae = sushi[N - i].first;
    }
    ll seki[N + 1] = {};
    for(ll i = 0; i < N; i++) seki[i + 1] = max(seki[i], yo[i + 1]);
    ll ans = 0;
    for(ll i = 0; i <= N; i++){
        ans = max(ans, po[i]);
        ans = max(po[i] - sushi[i].first + seki[N - i], ans);
    }
    for(ll i = 0; i < N; i++) seki[i + 1] = max(seki[i], po[i + 1]);
    for(ll i = 0; i <= N; i++){
        ans = max(ans, yo[i]);
        ans = max(yo[i] - (C - sushi[N - i + 1].first) + seki[N - i], ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T>& vs) {
    if (vs.empty()) return os << "[]";
    os << "[" << vs[0];
    for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
    return os << "]";
}
 
const double EPS = 1e-7;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }
};
double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt(dot(a, a)); }
Point rot90(const Point& p) { return Point(p.y, -p.x); } // 時計回りに90度回転 
ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }

typedef vector<Point> Polygon;
double area(const Polygon& vs) {
    assert(vs.size() >= 3);
    double r = 0;
    const Point& p = vs[0];
    for (int i = 1; i < vs.size() - 1; i++) {
        const Point& a = vs[i];
        const Point& b = vs[i + 1];
        r += cross(a - p, b - p);
    }
    return r / 2;
}

int main() {
    int N; cin >> N;
    Polygon P(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    cout << fixed << setprecision(1) << area(P) << endl;
    return 0;
}

Measured memory_bytes: 1296
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>

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

  int res = 1000;
  for (size_t i = 3; i <= S.length(); ++i) {
    std::string t(S.begin()+i-3, S.begin()+i);
    res = std::min(res, abs(std::stoi(t)-753));
  }
  std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)puts("Balanced");
	else if(a+b>c+d)puts("Left");
	else puts("Right");
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<ll> A(N); cin >> A;        
        ll ans = INFL;
        {
            ll sum = 0, cnt = 0;
            rep(i, N) {  
                sum += A[i];
                if(i % 2 == 0 and sum <= 0) {
                    cnt += abs(sum) + 1;
                    sum = 1;
                } else if(i % 2 == 1 and sum >= 0) {
                    cnt += abs(sum) + 1;
                    sum = -1;
                }
            }
            set_min(ans, cnt);
        }
        {
            ll sum = 0, cnt = 0;
            rep(i, N) {
                sum += A[i];
                if(i % 2 == 1 and sum <= 0) {
                    cnt += abs(sum) + 1;
                    sum = 1;
                } else if(i % 2 == 0 and sum >= 0) {
                    cnt += abs(sum) + 1;
                    sum = -1;
                }
                
            }
            set_min(ans, cnt);
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 1024
from collections import deque
S = deque(list(input()))
Q = int(input())

flag = False
for _ in range(Q):
  query = input().split()
  if query[0] == '1':
    flag = not flag
  elif query[0] == '2':
    left = query[1] == '1'
    if flag:
      left = not left
    if left:
      S.appendleft(query[2])
    else:
      S.append(query[2])

if flag:
  print(''.join(reversed(S)))
else:
  print(''.join(S))


Measured memory_bytes: 8420
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

ll N,M;
vector<ll> AList;
vector<ll> SList;

bool isSutisfiedShaakeHands(ll X) {
    ll cnt = 0;
    for (int i=0; i<N; i++) {
        int idx_lower = lower_bound(AList.begin(), AList.end(), X-AList[i]) - AList.begin();
        cnt += (N-idx_lower);
    }
    return (cnt >= M);
}

int main() {
    // input, ready
    cin >> N >> M;
    AList.resize(N);
    for(int i=0; i<N; i++) cin >>AList.at(i);
    sort(AList.begin(), AList.end());

    // resolve
    ll maxHappiness = 1e17;
    ll minHappiness = 0;
    while((maxHappiness - minHappiness) > 1) {
        ll X = (maxHappiness + minHappiness) / 2;
        if (isSutisfiedShaakeHands(X)) minHappiness = X;
        else maxHappiness = X;
    }

    ll ans = 0;
    ll cnt = 0;
    SList.resize(N+1);
    SList[0]=0;
    for(int i=0; i<N; i++) SList[i+1] = SList[i] + AList[i];
    for (int i=0; i<N; i++) {
        int idx_lower = upper_bound(AList.begin(), AList.end(), minHappiness-AList[i]) - AList.begin();
        ans += (SList[N]-SList[idx_lower]) + AList[i] * (N-idx_lower);
        cnt += N - idx_lower;
    }

    cout << ans + (M-cnt) * minHappiness << endl;

    return 0;
}


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

int main() {
  int a,b,c,d,e,f;
  cin >> a;
  
  b=a/1.08;
  c=(b+1)*1.08;
  d=(b+2)*1.08;
  e=a/1.08+1;
  f=a/1.08+2;
    
  if(b*1.08==a)
    cout << b << endl;
  else if(c==a)
    cout << e <<endl;
  else if(d==a)
    cout << f <<endl;
  else
    cout << ":(" << endl;
  
}


Measured memory_bytes: 256
#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;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    if(a[0] != 0){
        cout << -1 << endl;
        return;
    }
    ll res = 0;
    rep(i, N-1){
        if(a[i+1]-a[i] > 1){
            cout << -1 << endl;
            return;
        }
        if(a[i]+1 == a[i+1]) res++;
        else res += a[i+1];
    }
    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: 5888
#include <bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int h, n;
  cin >> h >> n;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    h -= a;
  }
  string ans;
  if(h<=0) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


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

int main(){
  int64_t n,m;
  const int64_t mod=1000000007;
  cin >> n >> m;
  if(abs(n-m)>1){
    cout << '0' << endl;
  }else{
    int64_t ans=1;
    for(int i=1;i<=n;i++){
      ans*=i;
      ans%=mod;
    }
    for(int i=1;i<=m;i++){
      ans*=i;
      ans%=mod;
    }
    if(m==n){
      ans*=2;
      ans%=mod;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
// #include</Users/sudhirpratap/Desktop/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define forn(i,n) for(int i = 0; i<n; i++)
#define forabc(a,b,c) for(int j=a; j<b; j+=c)
#define pb(a) push_back(a);
const long long MOD  = 1e9 + 7;
typedef long long ll;


int main() {
	//code
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("op.txt","w",stdout);
	// #endif
	std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

	double a, b;
	cin >> a >> b;
	cout<<fixed<<setprecision(10)<<a/b<<'\n';
	// #ifndef ONLINE_JUDGE
	// 	cout<<"Time elapsed: "<< 1.0*clock()/CLOCKS_PER_SEC << " s.\n";
	// #endif
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  vector<int> dp(100010);
  dp[0] = 0;
  for (int n = 1; n <= 100000; n++){
    dp[n] = INF;
    int power = 1;
    while (power <= n){
      dp[n] = min(dp[n], dp[n - power] + 1);
      power *= 6;
    }
    power = 1;
    while (power <= n){
      dp[n] = min(dp[n], dp[n - power] + 1);
      power *= 9;
    }
  }
  int N;
  cin >> N;
  cout << dp[N] << endl;
}



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


int main()
{
	int max;
	int currentSum;
	int loop;
	int a[5005];

	while (cin >> loop, loop) {
		// O(n)
		for (int i = 0; i<loop; i++) {
			cin >> a[i];
		}

		// O(n^2)
		max = a[0], currentSum = 0;
		for (int j = 0; j<loop; j++) {
			for (int k = j; k<loop; k++) {
				currentSum += a[k];
				if (currentSum > max)
					max = currentSum;
			}
			currentSum = 0;
		}
		cout << max << endl;
	}
	return 0;
}


Measured memory_bytes: 2972
N,Y = map(int, input().split())
a,b,c = -1,-1,-1
for i in range(N + 1):
    for j in range(N + 1 - i):
        k = N - i - j
        if 10000*i + 5000*j + 1000*k == Y:
            a,b,c = i,j,k
 
print(a,b,c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int x; cin>>x;
	YES(x==3||x==5||x==7);
}


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

signed main(){
  vector<int> A(32);
  A = { 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 << A.at(K-1) << endl;
  
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		
		int r = scan.nextInt();
		int c = scan.nextInt();
		int[][] numbers = new int[r + 1][c + 1];
		
		int sUB = 0;
		
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				numbers[i][j] = scan.nextInt();
			}
		}
		
		for(int k = 0; k < r; k++){
			int sB = 0;
			for(int l = 0; l < c; l++){
				sB = numbers[k][l] + sB;
			}
			numbers[k][c] = sB;
		}
		
		for(int l = 0; l < c; l++){
			int sU = 0;
			for(int k = 0; k < r; k++){
				sU = numbers[k][l] + sU;
			}
			numbers[r][l] = sU;
			
			sUB = numbers[r][l] + sUB;
		}
		numbers[r][c] = sUB;
		
		for(int p = 0; p < r + 1; p++){
			for(int q = 0; q < c + 1; q++){
				System.out.print(numbers[p][q]);
				if(q == c){
					System.out.print("");
				}else{
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 42264
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
const int N = 400005;
string s;
int n,k,c;
int dp[N], mx[N];
deque<int>q;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>k>>c;
    cin>>s;
    for(int i = n - 1; i >=0;--i){
        if(s[i]=='o') dp[i] = mx[i+c+1] + 1;
        mx[i] = max(dp[i], mx[i+1]);
    }
    int pos = 0;
    for(int i = k; i >= 1; --i){
        for(int j = pos; j < n; ++j){
            if(dp[j] >= i){
                q.push_back(j);
            }else{
                if(mx[j] < i) {
                    pos = j;
                    break;
                }
            }
        }
        if(q.size() == 1) cout << q[0]+1 <<"\n";
        int t = q[0];
        pos = max(pos, q[0]+c+1);
        while(q.size() > 0 && t+c+1 > q[0]) q.pop_front();
    }
    return 0;
}



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

using namespace std;

typedef pair<int, int> pii;
#define all(v) v.begin(), v.end()

int t, n;
vector<pii> obj;

int sx, sy;
set<pii> reach;

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

struct State {
	pii p; int turn;
	State (pii _p, int _t) : p(_p), turn(_t) {}
};

void solve() {
	queue<State> q;
	q.push(State(make_pair(sx, sy), 0));
	
	while (!q.empty()) {
		State s = q.front(); q.pop();
		
		if (reach.find(s.p) != reach.end()) continue;
		if (binary_search(all(obj), s.p)) continue;
		if (s.turn > t) continue;
		
		reach.insert(s.p);
		
		for (int i = 0; i < 6; i++) {
			int x = s.p.first + dx[i], y = s.p.second + dy[i];
			q.push(State(make_pair(x, y), s.turn + 1));
		}
	}
	
	cout << (int)reach.size() << endl;
}

int main() {
	while (1) {
		cin >> t >> n; if (t == 0 && n == 0) break;
		
		obj.clear();
		for (int i = 0; i < n; i++) {
			int x, y; cin >> x >> y;
			obj.push_back(make_pair(x, y));
		}
		sort(all(obj));
		
		reach.clear();
		cin >> sx >> sy;
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1380
#include <stdio.h>

int main(){
	int a,b,c,ans1=0,ans2=0;
	
	while( scanf("%d,%d,%d", &a,&b,&c) != EOF ){
		if(a*a+b*b==c*c) ans1++;
		else if(a==b) ans2++;
	}
	printf("%d\n%d\n", ans1,ans2);

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        int res = 0;
        for (int i = 1; i <= n; i++) {
            final int curr = in.nextInt();
            if (i % 2 != 0 && curr % 2 != 0) {
                res++;
            }
        }
        in.nextLine();
        System.out.println(res);
    }
}


Measured memory_bytes: 35964
#include<stdio.h>
int main(void){
  int num;
  int money;
  int tenFour,fiveThree,tenThree;
  int breakFrag = 0;
 
  if(scanf("%d %d",&num,&money));
  
  for(tenFour=0;tenFour<=num;tenFour++){
    if(breakFrag == 1)
        break;
    for(fiveThree=0;fiveThree<=num-tenFour;fiveThree++){
      if(breakFrag == 1)
        break;
      for(tenThree=0;tenThree<=num-tenFour-fiveThree;tenThree++){        
        if(money == 10000*tenFour + 5000*fiveThree + 1000*tenThree && num == tenFour+fiveThree+tenThree){
          printf("%d %d %d",tenFour,fiveThree,tenThree);
          breakFrag += 1;
          break;
        }
      }
    }
  }
  if(breakFrag == 0)
    printf("-1 -1 -1");
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	ll n;
	cin >> n;
	bool judge = true;
	vector<pair<ll, ll>>p(n);
	repp(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		p[i].first = b; p[i].second =a;
	}
	sort(p.begin(), p.end());
	ll sum = 0;
	repp(i, 0, n) {
		sum += p[i].second;
		if (sum > p[i].first)judge = false;
	}
	if (judge)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
	return 0;
}

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

using namespace std;

int main(){
  int K=0;

  cin>>K;
  auto sum=3*K*K-3*K+1;

  for(auto i=2;i<=K;++i){
    for(auto j=i;j<=K;++j){
      auto gcdTmp=gcd(i,j);
      auto coef=(i==j)?1:2;
      for(auto l=2;l<=K;++l){
        sum+=coef*gcd(gcdTmp,l);
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,i,j,k,c,s=0;
	cin>>n;
	vector<ll> v,vv;
	for(i=0;i<=n;i++) v.push_back(0);
	for(i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		vv.push_back(a);
		v[a]++;
	}
	vector<ll> vvv;
	for(i=0;i<=n;i++) vvv.push_back(0);
//	for(i=0;i<=n;i++) cout<<v[i]<<endl;
	for(i=1;i<=n;i++)
	{
		if(v[i]>1) vvv[i]=v[i]*(v[i]-1)/2;
	}
	for(i=1;i<=n;i++) s=s+vvv[i];
//	cout<<s;
	for(i=0;i<n;i++)
	{
		cout<<s-v[vv[i]]*(v[vv[i]]-1)/2+(v[vv[i]]-1)*(v[vv[i]]-2)/2<<endl;
	}
}

Measured memory_bytes: 7408
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,K,ans = -(1e9+7);
    cin >> N >> K;
    vector<ll> V(N);
    rep(i,N){
        cin >> V[i];
        V[i] *= -1;
    }
    priority_queue<int> q;
    for(int a=0;a<=K;a++){
        for(int b=0;b<=K;b++){
            if(a+b>K)continue;
            if(a+b>N)continue;
            // 左からa個 右からb個出す
            for(int i=0;i<a;i++){
                q.push(V[i]);
            }
            for(int i=0;i<b;i++){
                q.push(V[N-1-i]);
            }
            for(int i=0;i<K-a-b;i++){
                if(q.size()==0)break;
                if(q.top()<=0)break;
                q.pop();
            }
            int t = 0;
            while(!q.empty()){
                t -= q.top();q.pop();
            }
            ans = max(ans,t);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

S = [""]*N

Dict={}

ac=0
wa =0
tle =0
re=0


for i in range(N):
    S[i] = str(input())
    
for  j in S:
    if j in  Dict:
        temp = Dict[j]
        Dict[j] = temp + 1
    else:
        Dict[j] = 1
        
if "AC" in Dict:
    ac = Dict["AC"]
    
if "WA" in Dict:
    wa = Dict["WA"]
    
if "TLE" in Dict:
    tle = Dict["TLE"]
    
if "RE" in Dict:
    re = Dict["RE"]
    
    
print("AC x " , ac)
print("WA x " , wa)
print("TLE x " , tle)
print("RE x " , re)

Measured memory_bytes: 15948
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    int y = sc.nextInt();
    int count = 0;

    for(int i = 0 ; i < x + 1; i++){
        int checker = i * 2 + (x - i) * 4;
        if(checker == y){
            count++;
        }
    }

    if(count == 0){
        System.out.println("No");
    }else{
        System.out.println("Yes");
    }
    

    


    
    


    


    
    


    
	}
}

Measured memory_bytes: 35736
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n,m=map(int,input().split())
    AB=[]
    for i in range(m):
        a,b=map(int,input().split())
        AB.append(a)
        AB.append(b)
    abc=list(Counter(AB).values())
    print("YES" if all(x%2==0 for x in abc) else "NO")


if __name__=='__main__':
    main()

Measured memory_bytes: 57052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll a[200010];

void solve(){

    ll n;
    cin >> n;
    set<ll> st;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    cout << (st.size()==n? "YES": "NO") << endl;
 
}

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


Measured memory_bytes: 9600
program main;
var
  i, c, n : longint;
  s : string;

begin
  readln(n);
  readln(s);
  c := 0;
  for i := 1 to n do begin
    if (s[i] + s[i+1] + s[i+2] = 'ABC') then inc(c);
  end;
  writeln(c);
end.

Measured memory_bytes: 1392
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;

  return 0; 
}



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

int n, a[54];
int lo, hi;

int main() {
	cin>>n;
	for(int i = 1; i<=n;i++)	cin>>a[i];
	hi = max_element(a+1,a+n+1)-a;
	lo = min_element(a+1,a+n+1)-a;
	cout<<2*n-2<<'\n';
	if(abs(a[hi])>=abs(a[lo])){
		for(int i = 1;i<=n;i++){
			if(i != hi)	cout<<hi<<" "<<i<<"\n";
		}
		for(int i = 2;i<=n;i++)
			cout<<i-1<<" "<<i<<'\n';
	}
	else{
		for(int i = 1;i<=n;i++){
			if(i != lo)	cout<<lo<<" "<<i<<"\n";
		}
		for(int i = n-1;i>=1;i--)
			cout<<i+1<<" "<<i<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
if A[0]:
    print(-1)
    exit()
ans = 0
dp = A[-1]
for i in range(N - 1, 0, -1):
    if A[i - 1] == A[i] - 1:
        continue
    elif A[i - 1] >= A[i]:
        ans += dp
        dp = A[i - 1]
    else:
        print(-1)
        exit()
print(ans + dp)


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

using namespace std;

int main(void){
    int N;
    int ans = 0;
    vector<int> flowers;

    cin>>N;
    flowers.resize(N);

    for(int i=0; i<N; i++) cin>>flowers[i];

    while(true){
        if(*max_element(flowers.begin(), flowers.end()) == 0)break;

        int i = 0;
        while(i < N){
            if(flowers[i]==0)i++;
            else{
                ans++;
                while(i<N && flowers[i] > 0){
                    flowers[i]--;
                    i++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
abcd=input()
for i in range(1 << 3):
    l=[]
    for j in range(3):
        l.append(abcd[j])
        if (i>>j)&1==1:
            l.append('+')
        else:
            l.append('-')
    l.append(abcd[3])
    if eval("".join(l))==7:
        ans="".join(l)
        break
print(ans+"=7")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl "\n"
#define mod 1000000007
#define INF 1e18
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define w(x) int x; cin >> x; while (x--)

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void rwf()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int xpowery(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x) % mod;
		x = (x * x) % mod;
		y = y / 2;
	}
	return ans;
}

int32_t main()
{
	IOS;
	//rwf();

	int n, m;

	bool ok = false;

	cin >> n >> m;

	vector<int> final(n, 0);
	for (int i = 0; i < m; i++)
	{
		int s, c;
		cin >> s >> c;
		if (s - 1 == 0 && c == 0 && n != 1)
			ok = true;
		else
		{
			if (final[s - 1] == 0 || final[s - 1] == c)
				final[s - 1] = c;
			else
				ok = true;
		}
	}
	if (ok)
		cout << "-1";
	else
	{
		if (final[0] == 0 && n != 1)
			final[0] = 1;
		if (final[0] == 0 && n == 1)
			final[0] = 0;
		for (int i = 0; i < n; i++)
			cout << final[i];
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int a;
		int b;
		
		a = input.nextInt();
		b = input.nextInt();
		input.close();
		if(GreatestCommonDivisor(a,b) != -1) {
			System.out.println(GreatestCommonDivisor(a,b));
			
		}
		

	}
	
	public static int GreatestCommonDivisor(int a, int b) {
		if((a >= 1) && (a <= 1000000000) && (b >= 1) && (b <= 1000000000)) {
			
			if(a > b) {
				if((a % b) == 0) {
					return b;
				}
				else {
					return GreatestCommonDivisor(b, a % b);
				}
			}
			else if(b > a) {
				if((b % a) == 0) {
					return a;
				}
				else {
					return GreatestCommonDivisor(a, b % a);
				}
			}
			else {
				return a;
			}
		}
		else {
			System.out.println("Enter a number between 1 and 1000000000 for both numbers.");
			return -1;
		}
		
	}
	

}



Measured memory_bytes: 26320
X, K, D = map(int, input().split())

ans = None

if K*D <= abs(X):
    print(abs(X)-abs(K*D))
else:
    times0 = abs(X) // D
    X = abs(X) - times0 * D
    K -= times0
    if K % 2 == 0:
        print(X)
    else:
        print(abs(X-D))

Measured memory_bytes: 9180
def m():
    N, K = map(int, input().split())
    S = input()
    comp = []
    prev = S[0]
    cnt = 1
    for i in range(1, N):
        if prev == S[i]:
            cnt += 1
            prev = S[i]
        else:
            comp.append(cnt)
            prev = S[i]
            cnt = 1
    comp.append(cnt)
    comp_n = len(comp)
    acum = [0] * (comp_n + 1)
    acum[0] = 0
    if comp_n < (2*K):
        return N
    for i in range(comp_n):
        acum[i + 1] = comp[i] + acum[i]
    ans = 0
    if S[N - 1] == '0':
        ans = max(acum[comp_n] - acum[comp_n - (2 * K)], ans)

    if S[0] == '0':
        ans = max(acum[2 * K], ans)
    left = 1 if S[0] == '0' else 0
    right = left + (K*2+1)
    while right <= comp_n:
        t = acum[right] - acum[left]
        ans = max(ans, t)
        right +=2
        left +=2
    return ans


print(m())


Measured memory_bytes: 77908
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){

    int N; cin >> N;

    vector<int> depos;

    int tmp = 1;
    while (N >= tmp){
        depos.push_back(tmp);
        tmp*=6;
    }

    tmp = 9;
    while (N >= tmp){
        depos.push_back(tmp);
        tmp*=9;
    }

    //vector<vector<int>> dp(depos.size()+1,vector<int>(N+1,100000000));
    vector<int> dp(N+1,100000000);
    //dp[0][0] = 0;
    dp[0] = 0;

    //cout << depos.size() << endl;

    rep(i,depos.size()){
        rep(j, N){
            if (j+depos[i] > N) continue;
            dp[j+depos[i]] = min(dp[j+depos[i]], dp[j]+1);
        }
    }

    cout << dp[N] << endl;


}

Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int main(){
	int x=0;
	int h=0;
	int n=0;
	int m=0;
	int s=0;
	cin>>x;
	n=x/60;
	s=x-60*n;
	h=n/60;
	m=n-60*h;
	cout<<h<<":"<<m<<":"<<s<<endl;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const ll p=1000000007;
const int maxn=2e4+5;
int d,a[maxn];
ll dp[maxn][200];

ll dfs(int pos,int sum,int limit){
	if(pos==-1) return sum%d==0;
    if(!limit && dp[pos][sum]!=-1) return dp[pos][sum]%p;
    int up=limit ? a[pos] : 9;
    ll ans=0;
    for(int i=0;i<=up;i++){
        ans+=dfs(pos-1,(sum+i)%d,limit && i==a[pos]);
        ans%=p;
    }
    if(!limit) dp[pos][sum]=ans;
    return ans;
}

ll solve(string x){
	memset(dp,-1,sizeof(dp));
	int pos=0;
	for (int i=x.size()-1;i>=0;i--){
		a[pos++]=x[i]-'0';
	}
	return dfs(pos-1,0,1);
}

int main(){
	string k;
	cin>>k>>d;
	cout<<(solve(k)+p-1)%p;
}

Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  int N=S.size();
  int K=T.size();
  bool flag=false;
  vector<string>Ans;
  for(int i=0;i<N-K+1;i++){
    string SSS=S;
    string SS=S.substr(i,K);
    bool flag2=true;
    for(int j=0;j<K;j++){
      if(SS.at(j)!='?'&&SS.at(j)!=T.at(j)){
        flag2=false;
        break;
      }
    }
    if(flag2){
      flag=true;
      for(int j=0;j<K;j++){
        SSS.at(i+j)=T.at(j);
      }
      for(int i=0;i<N;i++){
        if(SSS.at(i)=='?'){
          SSS.at(i)='a';
        }
      }
      Ans.push_back(SSS);
    }
  }
  if(flag==false){
    cout<<"UNRESTORABLE"<<endl;
  }
  else{
    sort(Ans.begin(),Ans.end());
    cout<<Ans[0]<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;


bool check(map<char,int> num, set<char> can, char max_per, int nokori){
	auto itr = can.begin();
	for (int i = 0; i < can.size(); i++) {
		if (num[max_per] < num[*itr] + nokori and max_per != *itr ) {
			return false;
		}
		itr++;
	}
	return true;
}
int main() {
	while(1){
		int n; cin >> n;
		if (n == 0) break;
		
		vector<char> vote(n);
		set<char> can;
		map<char,int> num;
		int max = 0;
		char max_per;
		can.insert('x');
		for (int i = 0; i < n; i++) {
			cin >> vote[i];
			can.insert(vote[i]);
			num[vote[i]]++;
			if (max < num[vote[i]]){
				max = num[vote[i]];
				max_per = vote[i];
			}
		}
		//TIE????¢????
		int cnt = 0;
		auto itr = can.begin();
		for (int i = 0; i < can.size(); i++){
			if (num[*itr] == max){
				cnt++;
			}
			itr++;
		}
		//????????°?¶????????????´??????TIE ?¶???????????????????TIE????????????
		//int maj = (n / can.size()) + 1;
		if (cnt >= 2){
			cout << "TIE" << endl;
		}else{
			int ans = 0;
			map<char,int> num2;
			int maj;
			for (int i = 0; i < n; i++){
				ans++;
				num2[vote[i]]++;
				if (check(num2,can,max_per,n-i)){
					break;	
				}
			}
			cout << max_per << " " << ans << endl;	
		}
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> P(A);
  vector<ll> Q(B);
  vector<ll> R(C);
  vector<ll> ANS;
  ll ans = 0;
  rep(i, A) cin >> P.at(i);
  rep(i, B) cin >> Q.at(i);
  rep(i, C) cin >> R.at(i);
  sort(P.begin(), P.end());
  reverse(P.begin(), P.end());
  sort(Q.begin(), Q.end());
  reverse(Q.begin(), Q.end());

  rep(i, X) R.push_back(P.at(i));
  rep(i, Y) R.push_back(Q.at(i));
  sort(R.begin(), R.end());
  reverse(R.begin(), R.end());
  rep(i, X + Y) { ans += R.at(i); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6256
N,M = [int(i) for i in input().split()]
submissions = {str(i):[] for i in range(1,N+1)}
AC,WA = 0,0
for i in range(M):
    P,S = [j for j in input().split()]
    submissions[P].append(S)
for i in submissions:
    if 'AC' not in submissions[i]:
        continue
    for j in submissions[i]:
        if j == 'AC':
            AC+=1
            break
        WA +=1
print(AC,WA)

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    s[3]='8';
    cout<<s<<endl;
    return 0;
}

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

int main()
{
    string sta;

    cin >> sta;

    bool ans = false;
    char aorb;
    if (sta[0] != sta[1]) { ans = true; }
    if (sta[0] != sta[2]) { ans = true; }
    if (sta[1] != sta[2]) { ans = true; }

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

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
int main() {
    char s[1201] = {'\0'};
    scanf("%[^\n]", s);
    for (char* pc = s; *pc != '\0'; pc++) {
        // *pc ??? \0 ??????????????§?????????
        if ('a' <= *pc && *pc <= 'z') *pc = toupper(*pc);
        else if ('A' <= *pc && *pc <= 'Z') *pc = tolower(*pc);
    }
    printf("%s\n", s);
    return 0;
}

Measured memory_bytes: 3152
import Foundation

func readInt() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let line = readInt()
    let N = line[0]
    let M = line[1]
    let X = line[2]

    let books = (1...N).map { _ in readInt() }
    var ans = Int.max
    for bit in 0..<(1<<N) {
        var comb = [Int](repeating: 0, count:M+1)
        for i in 0..<N {
            if bit & (1 << i) > 0 {
                let book = books[i]
                comb = comb.enumerated().map { $1 + book[$0] }
            }
        }
        if comb[1...].allSatisfy({ $0 >= X }) {
            ans = min(ans, comb[0])
        }
    }

    if ans == Int.max {
        print(-1)
    } else {
        print(ans)
    }
}


main()

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

typedef int in;
#define int long long
int MAX=1e9;
int MAXEST=1e18;
int MOD=1e9+7;

int n,w;
int v[105],s[105];
int dp[105][100005];

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>n>>w;
        for(int i=1;i<=n;i++){
            cin>>s[i]>>v[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=0;j<=w;j++){
                dp[i][j]=dp[i-1][j];
                if(j>=s[i])
                    dp[i][j]=max(dp[i][j],dp[i-1][j-s[i]]+v[i]);
            }
        }
        cout<<dp[n][w]<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char c; cin >> c;
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

# N = 39
# S = 'RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB'

n_R = S.count('R')
n_G = S.count('G')
n_B = S.count('B')
ans = n_R * n_G * n_B

for b in range(1, N // 2 + 1):
    # b = 2
    for a in range(N - 2 * b):
        # a = 1
        i = a
        j = a + b
        k = a + 2 * b

        if k > N - 1:
            continue

        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)


Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define ub upper_bound
#define lb lower_bound
#define F first
#define S second

int main(){
    fastio;
    int k,a,b;
    cin >> k >> a >> b;

    if(a%k == 0 || b%k == 0) cout << "OK\n";
    else{
        int m = a/k;
        if(b >= k*(m+1)) cout << "OK\n";
        else cout << "NG\n";
    }
    return 0;
}

Measured memory_bytes: 3648