akhauriyash/Code-Regression huggingface dataset:
/* VERSION 5763 */
#include<iostream>
#include<stdlib.h>
using namespace std;
#define MAX 1000

int Stack[MAX], top;
int ERROR = 0;        // 0正常 -1栈满  -2栈空   

void initialize() {
    top = 0;
}

bool isEmpty() {
    return top == 0;
}

bool isFull() {
    return top >= MAX - 1; 
}

void push(int x) {
    if ( isFull() ) {
        ERROR = -1;
    } else {
        Stack[++top] = x;
    }
    
}

int pop() {
    if ( isEmpty() ) {
        ERROR = -2;
    } else {
        return Stack[top--];
    }
}

int main() {
    string s;
    int a, b;
    int check;
    initialize();
    
    while ( cin >> s ) {
        if ( s[0] == '+' ) {
            b = pop();
            a = pop();
            push(a + b);
        } else if ( s[0] == '-' ) {
            b = pop();
            a = pop();
            push(a - b);
        } else if ( s[0] == '*' ) {
            b = pop();
            a = pop();
            push(a * b);
        } else {
            push(atoi(s.c_str()));
        }
    }
    
    cout << pop() << endl;
    
    if ( ERROR ) cout << ERROR << endl;
    
    return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int k = s.size();
    int cnt = 0;
    for(int i = 0; i < k; i++){
        if(s[i] == 'o') cnt++;
    }
    if(15-k+cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

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

    int a=n/4,  b=n/7;

    bool ans=false;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            if(n==4*i+7*j) ans=true;
        }
    }
    if(ans) cout <<"Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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 namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    vecveci A(2,veci(N));
    REP(i,2) REP(j,N) cin >> A[i][j];
    int ans = 0;
    for(int i = 0; i <= N; i++) {
        int ret = 0;
        for(int j = 0; j <= i; j++) ret += A[0][j];
        for(int j = i; j < N; j++) ret += A[1][j];
        chmax(ans,ret);
    }
    cout << ans << endl;
}


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

bool check(vector<int> a) {
    for (int i = 0; i < a.size(); i++) {
        if (a[i] > 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++) {
        cin >> a[i];
    }
    
    int prev = -1;
    while(!check(a)) {
        int mx = 0;
        int mi = -1;
        for (int i = 0; i < t; i++) {
            if (mx < a[i] && prev != i) {
                mx = a[i];
                mi = i;
            }
        }
        if (mi != -1) {
            a[mi]--;
            prev = mi;
        } else {
            break;
        }
    }
    int ans = 0;
    for (int i = 0; i < t; i++) {
        if (a[i] > 0) {
            ans = a[i];
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = [_ for _ in input()]

rev = False

qn = int(input())

ins = []

for i in range(qn):
    q = input().split()
    if int(q[0])==1:
        rev = not rev
        continue

    if rev:
        if int(q[1])==1:
            s.append(q[2])
        else:
            ins.append(q[2])
    else:
        if int(q[1])==1:
            ins.append(q[2])
        else:
            s.append(q[2])

ins = ins[::-1]
ins.extend(s)

if rev:
    print("".join(ins[::-1]))
    exit()
print("".join(ins))



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

int main(){
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;
    for (int i=0; i<N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool can = true;
    for (int i=0; i<N; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;
    }

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

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>
#include <iomanip>

#define vec vector

using namespace std;

using ll = long long;
using vl = vector<long long>;
using vi = vector<int>;
using vvl = vector<vl>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using ld = long double;

int main()
{
    int n;
    cin >> n;
    vl a(n);
    for (auto &e : a)
        cin >> e;
    ll inf = numeric_limits<ll>::max();
    vvl dp(n, vl(n, inf)), cost(n, vl(n, 0));
    {
        vl prefix_sum(n);
        partial_sum(a.begin(), a.end(), prefix_sum.begin());
        for (int i = 0; i < n; i++)
            for (int j = 0; j <= i; j++)
                cost[j][i] = prefix_sum[i] - (j > 0 ? prefix_sum[j - 1] : 0);
    }
    for (int i = 0; i < n; i++)
        dp[i][i] = 0;
    for (int s = 1; s < n; s++)
        for (int j = 0; j + s < n; j++)
            for (int k = 0; k < s; k++)
                dp[j][j + s] = min(dp[j][j + s], dp[j][j + k] + dp[j + k + 1][j + s] + cost[j][j + k] + cost[j + k + 1][j + s]);
    cout << dp[0][n - 1];
    return 0;
}

Measured memory_bytes: 2816
#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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n, x, t, ans;
  cin >> n >> x >> t;
  if(n%x==0){
    ans = t * (n / x);
  }
  else{
    ans = t * (n / x + 1);
  }
  print(ans);
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <cstdio>
#define MAX 100010

using namespace std;

int n;
long long a,b;
long long h[MAX];

bool Judge(long long x)
{
    long long re;
    long long c=0;
    int i;
    for(i=0;i<n;i++)
    {
        re=h[i]-x*b;
        if(re<=0)
            continue;
        else
            {
                c+=re/(a-b);
                if(re%(a-b)!=0)
                    c++;
                if(c>x)
                    return false;
            }
    }
    return true;
}

int main()
{
    long long l=0,r=1e9,ans,count;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    ans=r;
    while(l<=r)
    {
        count=(l+r)/2;
        if(Judge(count))
        {
            r=count-1;
            ans=min(count,ans);
        }
        else
            l=count+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import Counter

N=int(input())
A=list(map(int,input().split()))
c=Counter(A)
c=c.most_common()
c.sort(reverse=True,key=lambda x:x[0])
cnt=0
H=0
W=0
for i in range(len(c)):
    if cnt==0 and c[i][1]>=4:
        H,W=c[i][0],c[i][0]
        print(H*W)
        exit()
    elif cnt==0 and c[i][1]>=2:
        H=c[i][0]
        cnt+=1
    elif cnt==1 and c[i][1]>=2:
        W=c[i][0]
        print(H*W)
        exit()
print(H*W)

Measured memory_bytes: 21540
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll N; ll M; cin >> N >> M;
    ll ans = 1;
    for(ll i = 1; i * i <= M; ++i) {
        if(M % i == 0) {
            if(M / i >= N)
                ans = max(ans, i);
            if(i >= N)
                ans = max(ans, M / i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 15;
LL a[MAXN],b[MAXN],x;
int main()
{
    int n,m,q;
    cin>>n>>m>>q;
    for(int i = 1;i <= n; ++i) cin>>a[i];
    for(int i = 1;i <= m; ++i) cin>>b[i];
    a[n+1] = 1e18;a[0] = -1e18;
    b[m+1] = 1e18;b[0] = -1e18;
    while(q--)
    {
        cin>>x;
        int aa = lower_bound(a+1,a+n+1,x) - a;
        int bb = lower_bound(b+1,b+m+1,x) - b;
        LL ans = 1e18;
        if(a[aa] < b[bb]){
            int pos = lower_bound(b+1,b+1+m,a[aa]) - b;
            ans = min(ans,a[aa]-x+min(b[pos]-a[aa],a[aa]-b[pos-1]));
        }
        else
        {
            int pos = lower_bound(a+1,a+1+n,b[bb]) - a;
            ans = min(ans,b[bb] - x + min(a[pos]-b[bb],b[bb]-a[pos-1]));
        }
        aa--;bb--;
        if(a[aa] > b[bb]){
            int pos = lower_bound(b+1,b+1+m,a[aa]) - b;
            ans = min(ans,x-a[aa]+min(b[pos]-a[aa],a[aa]-b[pos-1]));
        }
        else
        {
            int pos = lower_bound(a+1,a+1+n,b[bb]) - a;
            ans = min(ans,x-b[bb] + min(a[pos]-b[bb],b[bb]-a[pos-1]));
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXN = 100005;

ll A[MAXN], B[MAXN];

ll Ans;
int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];

	ll sum = 0;
	for(int i = N; i; i--) {
		A[i] += sum;
		ll t = A[i] % B[i];
		if(!t) continue;
		t = B[i] - t;
		Ans += t;
		sum += t;
	}

	cout << Ans << endl;

	return 0;
}

Measured memory_bytes: 1792
/*
//SOCS1:
#include <stdio.h>
#define ci(x) scanf("%d",&x);
#define cis(x) scanf("%s",&x);
#define cid(x) scanf("%f",&x);
#define cou(x) printf("%d",x);
#define cos(x) printf("%s",x);
#define cof(x) printf("%f",x);
//SOCS1: ( Tambahan, Bila Diperlukan )
#include <string>
#include <vector>
#include <algorithm>
//*/

///*
//CP:
#include<bits/stdc++.h>
using namespace std;
//highlight color RGB = [70,70,70]
#define asll unsigned long long
#define ll long long
#define ld long double
#define imt int
#define pii pair<int,int>
#define st first
#define nd second
#define kj <<" "<<
#define kjb <<" ";
#define dg <<","<<
#define ml <<endl;
#define co cout<<
#define ter cout<<endl;
#define sibi cout<<"TES"<<endl;
#define tes(x) cout<<"TES "<<x<<endl;
#define psbk(x) push_back(x);
#define For(x,a,b) for(int x=(a);x<(b);x++)
#define FOR(x,n) for(int x=0;x<(n);x++)
#define kera(x,m) for( int i = 0;i < m ; i++ ){ cout<<"x["<< i <<"] =" kj x[i] ml}
#define kpr(x) cout<<"("<<x.st dg x.nd <<")" ml
#define kkor(p) cout<<"("<<p.x dg p.y <<")" ml
#define m_p make_pair


#define dekar(b,x) int x[b];
#define gabung(x,p,q) void gab(int p,int q){p=cw(p);q=cw(q);x[p]=q;}
#define cariWakil(x,a) int cw(int a){ if(a==x[a]){ return a;} else{return x[a]=cw(x[a]);}}
#define init_dsu(b,x) void init_djs(){FOR(i,b){x[i]=i;}}
#define priksa(x,p,q) int cek(int p ,int q ){return x(p)==x(q);}
#define paket_djs(nama,b) dekar(b,nama)  init_dsu(b,nama)  cariWakil(nama,a)  gabung(nama,p,q)  priksa(cw,p,q)
 
paket_djs(induk,100005);
asll M=1e9+7;
int n,m,tc;
int p,q,r;
int frek[100005];
//*/

int main()
{
	//CP:
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
	//srand(time(0));
	init_djs();
	cin>>n>>m;
	FOR(i,m){
		cin>>p>>q;
		gab(p,q);
		//tgb[p]=1;
		//tgb[q]=1;
	}
	int hitung=0,sampah,tbs=0,itbs;
	For(i,1,n+1){
		sampah=cw(i);
		//co "is" kj i kj sampah ml
		frek[i]=0;
	}
	For(i,1,n+1){
		frek[induk[i]]++;
	}
	For(i,1,n+1){
		//co "i,frek" kj i kj frek[i] ml
		if(tbs<frek[i]){
			tbs=frek[i];
			itbs=i;
		}
	}
	For(i,1,n+1){
		if(i!=itbs && frek[i]!=0){
			hitung++;
		}
	}
	co hitung ml
}


Measured memory_bytes: 4416
n=int(input())
lista=[int(i) for i in input().split()]
n2=int(input())
listb=[int(i) for i in input().split()]
cnt=0


for i in listb:
    C=int(len(lista)/2)
    D=[0,len(lista)]
    while(1):
        if i<lista[C]:
            for k in D:
                if C>k:
                    d=k
                    break
            D.insert(0,C)
            C=int((C+d)/2)

        elif i>lista[C]:
            for k in D:
                if C<k:
                    d=k
                    break
            D.insert(0,C)
            C=int((C+d)/2)
        else:
            cnt+=1
            break
    
        if C==D[0]:
            break
    
        
print(cnt)


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

using namespace std;

typedef long long ll;

int main()
{
//	freopen("input.txt","r",stdin);
	
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.length();i++) sum+=(s[i]-'0');
	if(s=="0") cout<<"Yes"; 
	else if(sum%9) cout<<"No";
	else cout<<"Yes"; 
	
	return 0;
} 

Measured memory_bytes: 3376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#define lp(i, l, r) for (int i = l; i <= r; ++i)
#define rp(i, r, l) for (int i = r; i >= l; --i)
#define ls(i, s) for (int i = 0; s[i]; ++i)
#define rs(i, s) for (int i = strlen(s) - 1; i >= 0; --i)
#define lv(i, a) for (int i = 0; i < int(a.size()); ++i)
#define rv(i, a) for (int i = (int)a.size() - 1; i >= 0; --i)
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define prec(a) cout << setprecision(a) << fixed
#define appl(f, a) for (auto i = begin(a); i != end(a); f, ++i)
#define many for (int T = -1; T < 0 && cin >> T, T--;)
#define rang(a) begin(a), end(a)
#define gene template <class T>
#define endl '\n'
#define asse assert
using namespace std;
using namespace __gnu_pbds;
gene T inf() { return numeric_limits<T>::max(); }
gene int tmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
gene int tmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
gene auto min(const T &a) { return *min_element(rang(a)); }
gene auto max(const T &a) { return *max_element(rang(a)); }
gene auto sum(const T &a) { return accumulate(rang(a), 0); }
gene auto gath(const T &a, const vector<int> &b) {
    vector<typename T::value_type> r;
    for (auto i : b)
        r.push_back(a[i]);
    return r;
}
gene void sort(T &a) { sort(rang(a)); }
gene void reve(T &a) { reverse(rang(a)); }
gene void uniq(T &a) { sort(a), a.erase(unique(rang(a)), end(a)); }
gene void shuf(T &a) { random_shuffle(rang(a)); }
gene void merg(T l, T m, T r) { inplace_merge(l, m, r); }
// template <typename... T> void in(T &... a) { ((cin >> a), ...); }
// template <typename... T> void ou(T... a) { ((cout << a << ' '), ...); }
template <class F, class S> auto &operator>>(istream &s, pair<F, S> &a) {
    return s >> a.first >> a.second;
}
template <class F, class S> auto &operator<<(ostream &s, const pair<F, S> &a) {
    return s << '(' << a.first << ", " << a.second << ')';
}
gene auto &operator>>(istream &s, vector<T> &a) {
    for (int i = -1; i < 0 && (!a.size() && (cin >> i, a.resize(i), 0), i = 0),
             i < int(a.size());)
        s >> a[i++];
    return s;
}
gene auto &operator<<(ostream &s, const vector<T> &a) {
    lv(i, a) cout << a[i] << (i + 1 == int(a.size()) ? "" : " ");
    return s;
}
gene using bbst =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
gene using heap = __gnu_pbds::priority_queue<T, greater<T>, pairing_heap_tag>;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
int main() {
    fast, prec(12);
    int n;
    cin >> n;
    static int cnt[11][11];
    lp(i, 1, n) {
        auto s = to_string(i);
        cnt[s[0] - '0'][s.back() - '0']++;
    }
    ll ans = 0;
    lp(a, 1, 9) lp(b, 1, 9) { ans += ll(cnt[a][b]) * cnt[b][a]; }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,ans;
    ans = 0;
    scanf("%d%d%d",&a,&b,&c);
    for(int t=a;t<=b;t++){
        if(c%t==0){
            ans += 1;
        }
        else{
        }
        
        
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3212
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int a = int.Parse(Read.Str());
        List<string> blue = new List<string> { };
        for (int i = 0; i < a; i++)
        {
            blue.Add(Console.ReadLine());
        }
        int u = Read.Int();
        List<string> red = new List<string> { };
        for (int i = 0; i <u ; i++)
        {
            red.Add(Console.ReadLine());
        }
        int max = 0;
        for(int i = 0; i < blue.Count(); i++)
        {
            int mj = 0;
            for(int i1 = 0; i1 < blue.Count(); i1++)
            {
                if (blue[i] == blue[i1]) { mj++; }
            }
            for (int i1 = 0; i1 < red.Count(); i1++)
            {
                if (blue[i] == red[i1]) { mj--; }
            }
            max = Math.Max(mj,max);
        }
        Console.WriteLine(max);
        Console.ReadLine();


    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
import Data.List

func [a,b,c]
 |even a == even b && even b == even c = [a,b,c,0]
 |even a == even b = [a+1,b+1,c  ,1]
 |even a == even c = [a+1,b  ,c+1,1]
 |even b == even c = [a  ,b+1,c+1,1]

main = do
 list <- map read . words <$> getLine
 let [a,b,c,d] = func list
     largest = maximum [a,b,c]
 print $ d+abs (largest-a) `div` 2 + abs (largest-b) `div` 2 + abs (largest-c) `div` 2

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, x;
    cin >> n >> x;

    int64_t r = 0;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        r += a[i];
    }

    for (int k = 1; k < n; k++) {
        int64_t t = k * (int64_t)x;
        int a0 = min(a[0], a[n - 1]);
        for (int i = n - 1; i > 0; i--) {
            t += a[i] = min(a[i], a[i - 1]);
        }
        t += a[0] = a0;
        r = min(r, t);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        double x1,y1,x2,y2,x3,y3,x4,y4;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if(x1==x2||x3==x4){
            if(x1==x2&&x3==x4)puts("YES");
            else puts("NO");
        }
        else{
            double d=(y2-y1)/(x2-x1),d_=(y4-y3)/(x4-x3);
            if(d-d_<=0.0000001&&d-d_>=-0.0000001)puts("YES");
            else puts("NO");

        }
    }
    return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    map<int, int> ma;
    ll tot = 0;
    rep(i, n)
    {
        int a; cin >> a;
        ma[a]++;
        tot += a;
    }
    int q; cin >> q;
    rep(i, q)
    {
        int b, c; cin >> b >> c;
        int num = ma[b];
        int diff = c - b;
        tot = tot + (num * diff);
        cout << tot << endl;
        ma[c] += num;
        ma[b] -= num;
    }
}

Measured memory_bytes: 7928
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,i,n) lower_bound(v.begin()+i,v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mod 998244353
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
vector<l> fact(l n)
{
	vector<l> v;
	for(l i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			v.pb(i);
		}
	}
	return v;
}
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a)%mod;
		}
		b>>=1;
		a=(a%mod*a%mod)%mod;
	}
	return ans;
}//prefixsums
void frooty()
{

	l n;
	cin>>n;
	vector<l> v;
	for(l i=0;i<n;i++)
	{
		l a;
		cin>>a;
		v.pb(a);
	}
	sort1(v);
	bool dp[(l)1e6+3];
	mem(dp,1);
	bool fl[(l)1e6+3];
	mem(fl,0);
	for(l i=0;i<n;i++)
	{
		if(!fl[v[i]]){
		fl[v[i]]=true;
		for(l j=2*v[i];j<=(l)1e6;j+=v[i])
		{
			dp[j]=false;
		}
	}
	else
		dp[v[i]]=false;
	}
	l ans=0;
	for(l i=0;i<n;i++)
	{
		if(dp[v[i]]==true)
			ans++;
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 6876
# 入力
N, M = map(int, input().split()) # ノード数, エッジ数
edges = [[] for i in range(N)] # エッジ
for i in range(M):
    A, B = map(int, input().split())
    edges[A - 1] += [B - 1]
    edges[B - 1] += [A - 1]

# 幅優先探索
que = [0] # 探索用キュー
ans = [0] + [-1 for i in range(N - 1)] # 未探索ノード 兼 道しるべ
while -1 in ans: # 未探索ノードがある間
    quetmp = que
    que = []
    for node in quetmp: # 探索キュー内のノードに対して
        for neighbor in edges[node]: # 全ての隣接ノードに対して
            if ans[neighbor] == -1: # 未探索なら
                ans[neighbor] = node + 1 # 道しるべを設定
                que += [neighbor] # キューに入れる

# 出力
print('Yes')
for a in ans[1:]:
    print(a)


Measured memory_bytes: 37256
#include <stdio.h>

int main() {
    long long N,P,i=2,j,k,c=1,memo[80000]={2,3},e=0;
    int a;

    scanf("%lld %lld",&N,&P);
    
    if(N==1) {
        i=P+1;
        c=P;
    }

    for(;i<=P;i++) {
        a=0;

        for(j=1;memo[j]*memo[j]<=i;j++) {
            if(i%memo[j]==0) {
                a=1;
                i++;
                break;
            }
        }

        if(a==1) continue;

        k=1;
        j=1;
        while(j<=N) {
            k*=i;
            j++;
            if(k>P) {
                a=1;
                break;
            }
        }

        if(a==1) break;

        memo[e]=i;
        e++;

        while(P%k==0) {
            c*=i;
            P/=k;
        }
        while(P%i==0) P/=i;

        if(i!=2) i++;
    }

    printf("%lld\n",c);
    return 0;
}

Measured memory_bytes: 768
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair

int N;
LL m = LLONG_MAX;
int c = 0;
int main(){
	cin >> N;
	LL ans = 0;
	for(int i=0; i<N; i++){
		LL A;
		cin >> A;
		if(A < 0) c++;
		ans += abs(A);
		m = min(m, abs(A));
	}
	if(c%2 == 1) ans -= 2*m;
	cout << ans << endl;
}

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

using namespace std;
static const int MAX = 1400;
int G[MAX][MAX], dp[MAX][MAX];
int getLargestSquare( int H, int W ) {
	int maxWidth = 0;

    for( int i = 0; i < H; i++ )
    	for( int j = 0; j < W; j++ ) {
    	   		dp[i][j] = !G[i][j] ;
    	   		maxWidth |= dp[i][j];
    	}
    
    for( int i = 1; i < H; i++ )
    	for( int j = 1; j < W; j++ ) {
    		if( G[i][j] ) dp[i][j] = 0;
    		else {
    			dp[i][j] = min( dp[i -1][j -1], min(dp[i - 1][j], dp[i][j-1]) ) + 1;
    			maxWidth = max( maxWidth, dp[i][j]);
    		}
    	} 
	return maxWidth * maxWidth;
}
int main() {
	int H, W;

	cin >> H >> W;
	for( int i = 0; i < H; i++ )
		for( int j =0; j < W; j++ ) cin >> G[i][j];

	cout << getLargestSquare( H, W ) << endl;

}



Measured memory_bytes: 18340
#include"bits/stdc++.h"

using namespace std;

int main(void){
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(u==s){
    --a;
  }
  else{
    --b;
  }
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Integer[]> array = new ArrayList<>();
        int tmpNum;
        while((tmpNum = sc.nextInt()) != 0){
            int tmp = array.size();
            array.add(new Integer[2]);
            array.get(tmp)[0] = tmpNum;
            array.get(tmp)[1] = sc.nextInt();
        }
        String[] week = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
        for(Integer[] day : array){
        	int days = day[1];
            for(int i = day[0] - 1;i >= 1;i--){
                switch(i){
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
                   		days += 31;
             	      	break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:
                       days += 30;
                       break;
                    case 2:
                       days += 29;
                       break;
                }
            }
            System.out.println(week[(days + 3) % 7]);
        }
    }
}


Measured memory_bytes: 26108
//110 A - Maximize the Formula 2018/09/23
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    cout << a[0] + a[2]*10 + a[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

int n;
LL tot = 0;

int main(){
	n = re<int>();
	for (int i = 1, l, r; i <= n; i++){
		l = re<int>(); r = re<int>();
		tot += r - l + 1;
	}
	cout << tot << '\n';
	return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    print(n*800-200*(n//15))

#B
def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)

#C
def C():
    x,t = LI()
    print(max(0,x-t))

#D
def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

def J():
    return

def K():
    return

#Solve
if __name__ == "__main__":
    D()


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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int N; cin >> N;
        if (!N) break;
        vector<int> w(N);
        rep(i,N) cin >> w[i];

        vector<vector<int>> dp(N, vector<int>(N));
        for (int k = 1; k < N; k++) {
            rep(i,N-k) {
                if (abs(w[i]-w[i+k]) < 2 && dp[i+1][i+k-1] == k+1-2) dp[i][i+k] = dp[i+1][i+k-1]+2;
                else {
                    for (int j = 0; j < k; ++j) {
                        chmax(dp[i][i+k],dp[i][i+j]+dp[i+j+1][i+k]);
                    }
                }
            }
        }

        cout << dp[0][N-1] << ln;
    }
}


Measured memory_bytes: 3320
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main() {
	int n=read(),k=read();
	int ans=0;
	while (n) {
		n/=k;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct DATA{
  int ID;
  int Time;
};

bool compare(const DATA&, const DATA&);

int main(){
  int i, n;
  int c1, m1, s1, m2, s2, m3, s3, m4, s4;
  DATA _data;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; i++){
      cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
      _data.ID = c1;
      _data.Time = 60*(m1+m2+m3+m4) + s1+s2+s3+s4;
      data.push_back(_data);
    }

    sort(data.begin(), data.end(), compare);

    cout << data[0].ID << endl;
    cout << data[1].ID << endl;
    cout << data[data.size()-2].ID << endl;

    data.clear();
  }

  return 0;
}

bool compare(const DATA& x, const DATA& y){
  return (x.Time < y.Time);
}

Measured memory_bytes: 960
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  ll start;
  ll end;
  string s;
  ll cnt = 0;
  ll memo;
  ll digit;
  ll prememo;
  string getn = to_string(n);
  ll ns = atoi(getn.substr(0,1).c_str());
  ll ne = atoi(getn.substr(getn.size()-1,1).c_str());

  for(int i = 1; i <= n; i++){
    s = to_string(i);
    start = atoi(s.substr(0,1).c_str());
    end = atoi(s.substr(s.size()-1,1).c_str());
    if(end == 0) continue;
    if(start == end && start <= n) cnt++;
    memo = 10*end + start;
    digit = 10;
    for(int j = 1; j < getn.size(); j++){
      cnt += (ll) pow(10,j-2);
      if(j == getn.size()-1){
        if(memo <= n){
          if(end == ns){
              cnt += (n - ns*pow(10,j) - ne)/10 + 1;
              if(start > ne) cnt--;
          }else{
              cnt += pow(10,j-1);
          }
        }
      }
      if(memo <= n){
        memo -= digit*end;
        digit *= 10;
        memo += digit*end;
      }
    }
  }
  printf("%lld\n", cnt);
  return 0;
}


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

int main() {
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int64_t L,R;
  int ans=2018;
   int LL,RR;
    
  
  cin >> L >> R;
  
  
  if(R-L>=2019){
    ans =0;
  }
  
  
  else{
    
    LL = L%2019;
    RR = R%2019;
    
    
    if(LL<RR){
      
       for(int64_t i=LL;i<=RR-1;i++){
          for(int64_t j=i+1;j<=RR;j++){
            int a;
            a=((i%2019)*(j%2019))%2019;
                if(a<ans){
                    ans = a;
    		    }
   		  }
       }
    }
    else{
      ans =0;
    }
  }
  
  cout << ans << endl;
    
  }


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

	int N, a[1000],n,m,tmp=0;

	cin >> N;

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

	for (n = 0; n < N; n++) {

		for (m = 0; m < N; m++) {

			if (a[n] < a[m]) {

				tmp = a[m];
				a[m] = a[n];
				a[n] = tmp;

			}

		}

	}

	cout << a[N - 1] - a[0] << endl;

}

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

#define int long long

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

int N;
int t[100000], x[100000], y[100000];

signed main() {
    cin >> N;
    int ts = 0, xs = 0, ys = 0;
    for (int i = 0; i < N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < N; i++) {
        if (abs(xs - x[i]) + abs(ys - y[i]) > t[i] - ts || (abs(xs - x[i]) + abs(ys - y[i])) % 2 != (t[i] - ts) % 2) {
            cout << "No" << endl;
            return 0;
        }
        ts = t[i];
        xs = x[i];
        ys = y[i];
    }
    cout << "Yes" << endl;
    cout << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  int d[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &d[i]);
  }
  
  for (int j = 0;  j < N-1; j++) {
    for (int k = j; k < N; k++){
        if (d[j] == d[k] && j != k) {
          d[j] = 0;
        }
    }
  }
  
  int count = 0;
  
  for (int j = 0; j < N; j++) {
    if (d[j] != 0){
      count++;
    }
  }
  
  printf("%d", count);
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define MAX 100
static const int INFTY = (1<<21);
int n,A[MAX][MAX];

void dikusutora();

int main(){
  int i,j,m,k,d,h;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&m);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&d);
      scanf("%d",&h);
      A[m][d]=h;
    }
  }
  dikusutora();
  return 0;
}
void dikusutora(){
  int min,i,e,v;
  int g[MAX],a[MAX];

  for(i=0;i<n;i++){
    g[i]=INFTY;
    a[i]=0;
  }
  g[0]=0;
  a[0]=1;
  
  while(1){
    min=INFTY;
    e=-1;
    for(i=0;i<n;i++){
      if(min>g[i]&&a[i]!=2){
	e=i;
	min=g[i];
      }
    }
    if(e==-1)
      break;
    a[e]=2;
    for(v=0;v<n;v++){
      if(a[v]!=2&&A[e][v]!=INFTY){
	if(g[v]>g[e]+A[e][v]){
	  g[v]=g[e]+A[e][v];
	  a[v]=1;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",i);
    printf(" ");
    if(g[i]==INFTY)
      printf("-1");
    else printf("%d",g[i]);
    printf("\n");
  }
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long int N, A, B;
    cin >> N >> A >> B;
    
    if(A>B || (N==1 && A!=B)) {
        cout << 0 << endl;
        return 0;
    } else if(A==B||N==2) {
        cout << 1 << endl;
        return 0;
    }
    
    cout << (B-A)*(N-2)+1 << endl;

    return 0;
    
}

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

int main(){
    int A,B;
    cin >> A >> B;
    int ans = max(A+B, A-B);
    ans = max(ans, A*B);
    cout << ans << "\n";
    return 0;
}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  bool poor = true;
  if (a==b && b==c) poor = false;
  else if (a!=b && b!=c && c!=a) poor = false;
  
  if (poor) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	vector<bool>W(F + 1, false);
	vector<bool>S(F + 1, false);
	for (int i = 0; i <= F / (100 * A); ++i) {
		for (int j = 0; j <= F / (100 * B); ++j) {
			if ((i * 100 * A + j * 100 * B) <= F) {
				W[i * 100 * A + j * 100 * B] = true;
			}
		}
	}
	for (int i = 0; i <= F / C; ++i) {
		for (int j = 0; j <= F / D; ++j) {
			if ((i*C + j * D) <= F) {
				S[i*C + j * D] = true;
			}
		}
	}
	pair<int, int>ans = make_pair(100, 0);
	for (int i = 0; i <= F; ++i) {
		for (int j = 0; j <= F; ++j) {
			if ((W[i] && S[j]) && (i + j <= F)) {
				if ((j * 100) <= (i*E)) {
					if ((j*ans.first) >= (i*ans.second)) {
						ans = make_pair(i, j);
					}
				}
			}
		}
	}
	cout << ans.first + ans.second << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << 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 namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, t; cin >> n >> t;
	VE a(n); rep(i, n)cin >> a[i];
	int ans = t;
	rep(i, n - 1) {
		ans += min(t, a[i + 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

static const int N = 100;

void trace(int A[],int n){
	int i;
	for(i=1;i<=n;i++){
		if(i>1)      
		printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}
int main(void){
	int n,i,j,key;
	int A[N+1];
	scanf("%d",&n); 
	for(i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	trace(A,n);
	for(j=2;j<=n;j++){
		key=A[j];
		i=j-1;
		while(i>0 && A[i]>key){
			A[i+1]=A[i];
			i--;
		}
		A[i+1]=key; 
		trace(A,n); 
	}
	return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n;
	 cin>>n;
	 vector<pair<int,int>> v;
	 for(int i=0;i<n;i++)
	 {
		 int x,y;
		 cin>>x>>y;
		 v.push_back({x,y});
	 }
	 string ans = "No";
	 for(int i=0;i+2<n;i++)
	 {
		 if(v[i].first == v[i].second && v[i+1].first == v[i+1].second && v[i+2].first == v[i+2].second)
		 {
			 ans = "Yes";
			 break;
		 }
	 }
	 cout<<ans<<'\n';
	 return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int w[8][3]={{1,4,7},{2,5,8},{3,6,9},{1,2,3},{4,5,6},{7,8,9},{1,5,9},{3,5,7}};
char c[10];

int main(){
	while(cin>>c[1]){
		for(int i=2;i<10;i++)cin>>c[i];
		int flag=0;
		for(int i=0;i<8;i++){
			int p=0;
			for(int j=0;j<3;j++){
				if(c[w[i][j]]=='o')p++;
				if(c[w[i][j]]=='x')p--;
			}
			if(p==3){cout<<"o"<<endl;flag=1;break;}
			if(p==-3){cout<<"x"<<endl;flag=1;break;}
		}
		if(flag==0)cout<<"d"<<endl;
	}
}

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

typedef long long ll;

const int mod=1e9+7;

int phi(int n) {
	int result=n;
	for (int i=2; i*i<=n; i++) {
		if(n%i==0) result-=result/i;
		while(n%i==0) n/=i;
	}
	if(n>1) result-=result/n;
	return result;
}

// (a^b)%m
ll exp(ll a, ll b, ll m) {
	ll r=1;
	while(b) {
		if(b%2) r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

// a^-1 %m, any m
ll inv(ll a, ll m) {
	return exp(a, phi(m)-1, m);
}

// a^-1 %m, prime m
ll invp(ll a, ll m) {
	return exp(a, m-2, m);
}

// (a*b)%m
ll mul(ll a, ll b, ll m) {
	ll x=0, y=a%m;
	while(b>0) {
		if(b%2) x=(x+y)%m;
		y=(y*2)%m;
		b/=2;
	}
  return x%m;
}

// (a+b)%m
ll add(ll a, ll b, ll m) {
	return (a+b)%m;
}

const int mx=2e5+777;

ll fact[mx];

ll combi(int n, int x, ll m) {
	ll p=fact[n], q=fact[x], r=fact[n-x];
	ll ret=p;
	ret=(ret*invp(q,m))%m;
	ret=(ret*invp(r,m))%m;
	return ret;
}

bool isprime(int n) {
	if(n==1) return false;
	for (int i=2; i*i<=n; i++)
		if(n%i==0) return false;
	return true;
}

int gcd(int a, int b) {
	if(!b) return a;
	else return gcd(b,a%b);
}

ll ninv[mx];

ll eval(ll a, ll n) {
	a=min(a,n-a);
	ll ret=1;
	for (int i=0; i<a; i++)
		ret=(ret*(n-i))%mod,
		ret=(ret*ninv[i+1])%mod;
	return ret;
}

int main() {
	for (int i=1; i<mx; i++)
		ninv[i]=invp(i,mod);
	int n,a,b; cin>>n>>a>>b;
	ll ret=exp(2,n,mod);
	ret=(ret+mod-eval(a,n))%mod;
	ret=(ret+mod-eval(b,n))%mod;
	ret=(ret+mod-1)%mod;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        ans += a[i];
    }
    vector<vector<ll>> mi(n+1, vector<ll>(n+1));
    for(int i = 0; i < n; i++)
    {
        mi[i][0] = a[i];
        for(int j = 0; j < n; j++)
        {
            if(i-j-1 >= 0)
            {
                mi[i][j+1] = min(mi[i][j], a[i-j-1]);
            }
            else
            {
                mi[i][j+1] = min(mi[i][j], a[n+(i-j-1)]);
            }
        }
    }
    for(int num = 1; num < n; num++)
    {
        ll tmp = 0;
        for(int i = 0; i < n; i++)
        {
            tmp += mi[i][num];
        }
        tmp += x * num;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 31744