akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 1025*1005
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

int n,x[MAX],y[2],g;
bool f,m,o;

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

int main(){
	scanf("%d",&n);
	F1(a,0,n)scanf("%d",x+a);
	while(1){
		y[0]=y[1]=0;
		m=1-m;
		F1(a,0,n)y[x[a]&1]++;
		if(y[0]&1){
			f=m;
			break;
		}else if(y[1]>1){
			f=1-m;
			break;
		}else{
			F1(a,0,n)if(x[a]&1){
				if(x[a]==1)f=1-m,o=1;
				x[a]--;
				break;
			}
			if(o)break;
			g=x[0];
			F1(a,1,n)g=gcd(g,x[a]);
			F1(a,0,n)x[a]/=g;
		}
	}
	if(f)printf("First\n");
	else printf("Second\n");
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 512
import math
a, b = map(int, input().split())
x = math.ceil(a / 0.08)
y = math.ceil(b / 0.1)
if (x==y):
    print(x)
else:
    if x < y:
        if math.floor(math.ceil(b / 0.1) * 0.08) == a:
            print(y)
        else:
            print(-1)
    if x > y:
        if math.floor(x * 0.1)==b:
            print(x)
        else:
            print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

void solve(){
  string s; cin>>s;
  int cnt=0;
  for(int i=0 ; i<sz(s) ; i++){
    int ans=0;
    while(i<sz(s) && s[i]=='R'){
      i++;
      ans++;
    }
    cnt=max(cnt,ans);
  }
  cout<<cnt;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _=1; //cin>>_;
  while(_--) solve();
  return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string N; cin >> N;
    REP(i, N.length()) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

VV G;
ll d[1000][1000];
ll N, M;

VI get_path(ll i, ll j){
  VI rev(N, -1);
  vector<bool> visited(N, false);
  queue<ll> que;
  que.push(i);
  visited[i] = true;
  while(!que.empty()){
    ll from = que.front(); que.pop();
    for(ll to : G[from]){
      // まだ訪れていない点なら
      if(visited[to]) continue;

      visited[to] = true;
      rev[to] = from;
      que.push(to);
    }
  }
  VI ret;
  ret.push_back(j);
  
  ll now = j;
  while(true){
    ret.push_back(rev[now]);
    now = rev[now];
    if(now==i) return ret;
  }
}

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

    // input
    cin >> N >> M;

    G.resize(N);

    rep(i, 1000){
      rep(j, 1000){
        d[i][j] = inf;
      }
    }

    rep(i, M){
      ll a, b; cin >> a >> b;
      a--;
      b--;
      G[a].push_back(b);
      d[a][b] = 1;
    }

    // warshall
    FOR(i, 0, N){ // 経由点
        FOR(j, 0, N){ // 始点
            FOR(k, 0, N){ // 終点
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }

    ll mi = inf;
    ll min_i, min_j;
    rep(i, N){
      rep(j, N){
        if(mi > d[i][j] + d[j][i]){
          mi = d[i][j] + d[j][i];
          min_i = i;
          min_j = j;
        }
      }
    }

    if(mi==inf){
      p(-1);
      return 0;
    }
    
    VI path0 = get_path(min_i, min_j);
    VI path1 = get_path(min_j, min_i);
    
    set<ll> se;
    for(ll v : path0) se.insert(v);
    for(ll v : path1) se.insert(v);

    p(se.size());
    for(ll v : se){
      p(v+1);
    }
    
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#define endl '\n'
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
	while(n!=0)
	{
		if(n%10==7)
		{
			cout<<"Yes\n";
			return 0;
		}
		n/=10;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
/*
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
*/
ll mod = 1e9 + 7;
// abc145d
int main(void)
{
	std::cout << std::fixed << std::setprecision(10);
	int n, x[10], y[10], i, j, k;
	long double ans = 0;
	cin >> n;
	int f = 1;
	for (i = 1; i <= n;i++)
	{
		f *= i;
	}
	for (i = 1; i <= n; i++)
	{
		cin >> x[i] >> y[i];
	}
	int array[] = { 1,2,3,4,5,6,7,8 };
	do {
		long double dis=0;
		for (int i = 0; i < n-1; i++) {
			//i,i+1
			//printf("(%d,%d)", array[i], array[i+1]);
			dis += sqrt((x[array[i]]- x[array[i + 1]]) * (x[array[i]] - x[array[i + 1]]) + (y[array[i]]- y[array[i + 1]]) * (y[array[i]] - y[array[i + 1]]));
		}
		ans += dis;
	} while (next_permutation(array, array + n));
	cout << ans /f << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
for x in S:
    # print(x)
    if x == "a" and A + B > 0:
        if A > 0:
            A -= 1
            print("Yes")
        else:
            B -= 1
            print("Yes")
    elif x == "b" and A + B > 0 and B > 0:
        B -= 1
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 52952
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
a,b = input().split()
a = int(a)
b100 = 100*int(b[0]) + 10*int(b[2]) +int(b[3])

print(a*b100//100)


Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ priority_queue
#define print(x) cout<<(x)<<endl
using namespace std;            typedef vector<int>  vi;
typedef long long ll;           typedef vector< ll>  vl;
typedef unsigned long long ull; typedef vector<ull>  vu;
typedef double dbl;             typedef vector<dbl>  vd;
typedef pair<int,int>pii;       typedef vector<pii>vpii; typedef map<int,int>mii;
typedef pair< ll, ll>pll;       typedef vector<pll>vpll; typedef map< ll, ll>mll;
typedef pair<dbl,dbl>pdd;       typedef vector<pdd>vpdd; typedef map<dbl,dbl>mdd;
typedef pair< ll,int>pli;       typedef vector<pli>vpli; typedef map< ll,int>mli;
typedef pair<dbl,int>pdi;       typedef vector<pdi>vpdi; typedef map<dbl,int>mdi;
template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
template<typename T>set<T>&operator<<(set<T>&s,const T t){s.insert(t);return s;}
template<typename T,typename U>PQ<T,vector<T>,U>&operator<<(PQ<T,vector<T>,U>&q,const T t){q.push(t);return q;}
template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
template<typename T>istream&operator>>(istream&s,vector<T>&v){fr(i,v.size()){s>>v[i];}return s;}
template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
const int MD=1e9+7;
vpli dijkstra(const int N,const vpli E[],const int s,const ll inf){vpli d;fr(i,N)d<<pli{inf,i};d[s].first=0;PQ<pli,vpli,greater<pli>>pq;pq<<(d[s]=pli{0,s});while(pq.size()){pli a=pq.top();pq.pop();int v=a.second;if(d[v].first>=a.first){for(pli e:E[v]){if(d[v].first+e.first<d[e.second].first){d[e.second]=pli{d[v].first+e.first,v};pq<<pli{d[v].first+e.first,e.second};}}}}return d;}
ll gcd(const ll a,const ll b){return a?gcd(b%a,a):b;}
ll pow(const ll a,const ll n,const int m){ll t;return n?(n&1?a>=0?a%m:~-m+~a%m:1)*(t=pow(a,n>>1,m),t*t%m)%m:1;}
ll C2(const int n){return(ll)n*~-n/2;}
// (int) * (int) => (int)
// (int) / (int) => (int)

vi E[2000];
int f(int p,int i,int d){
	if(!d)return 1;
	int x=1;
	for(int j:E[i])if(j!=p){
		x+=f(i,j,d-1);
	}
	return x;
}
main(){cin.tie(0);ios::sync_with_stdio(false);
	int N,K;
	cin>>N>>K;
	fr(i,N-1){
		int A,B;
		cin>>A>>B;
		E[--A]<<--B;
		E[B]<<A;
	}
	int z=0;
	if(K%2){
		fr(i,N){
			for(int j:E[i])if(i<j){
				z=max(z,f(i,j,K/2)+f(j,i,K/2));
			}
		}
	}else{
		fr(i,N){
			z=max(z,f(i,i,K/2));
		}
	}
	print(max(0,N-z));
}


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

typedef long long ll;

// Vectors
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define print(msg) cout << msg << endl

const int INF = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> arr(n);
    ll total = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }

    int currMax = arr[0];
    for (int i = 1; i < n; ++i) {
        if (currMax > arr[i]) {
            total += (currMax - arr[i]);
        }
        currMax = max(currMax, arr[i]);
    }
    cout << total << "\n";

    return 0;
}

Measured memory_bytes: 3956
#include <stdio.h>

int n, A[50];

int solve(int i, int m){
  if( m==0 ) return 1;
  if( i>=n ) return 0;
  int res = solve( i+1, m ) || solve( i+1, m-A[i] );
  return res;
}


int main(){
  int q, i, M;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &M);
    if( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2692
def main():
    N = int(input())
    A = tuple([int(input()) for _ in range(N)])

    a = list(A)
    ans = 0
    try:
        idx = a.index(1)
    except:
        idx = 0
        ans += 1

    while True:
        btn = a[idx]
        if btn == 0:
            ans = -1
            break
        elif btn == 2:
            break
        a[idx] = 0
        idx = btn - 1
        ans += 1

    print(ans)

main()


Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,r;
    while (cin>>n>>r) {
        if (n==0&&r==0) {
            break;
        } else {
            std::deque<int> deq;
            for (int i=n;i>0;i--) {
                deq.emplace_back(i);
            }
            int p,c;
            for (int i=0;i<r;i++) {
                cin>>p>>c;
                std::deque<int> tmp;
                for (int i=0;i<c;i++) {
                    tmp.emplace_back(deq[p-1]);
                    deq.erase(deq.begin()+p-1,deq.begin()+p);
                }
                for (int i=tmp.size()-1;i>=0;i--) {
                    deq.emplace_front(tmp[i]);
                }
            }
            cout<<deq[0]<<endl;
        }
    }
}


Measured memory_bytes: 3048
N = input()
A = raw_input()
B = raw_input()
C = raw_input()
ans = 0

for i in xrange(N-1, -1, -1):
    S = set([A[i], B[i], C[i]])
    if len(S) == 2:
        ans += 1
    elif len(S) == 3:
        ans += 2

print ans


Measured memory_bytes: 2568
N=int(input())
S=["" for j in range(N)]
for i in range(N):
    S[i]=input()

ans=0
for i in range(0,N):
    ans+=N*int(all(S[(k+i)%N][j]==S[(j+i)%N][k] for j in range(N) for k in range(N)))

print(ans)


Measured memory_bytes: 74408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // [9,223,372,036,854,775,807 to -9.....808] 19 digits
typedef long double ld;
#define inc(i, a, b) for (long long int i = a; i <= b; i++)
#define dec(i, a, b) for (long long int i = a; i >= b; i--)
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define lv vector<ll>
#define cv vector<char>
#define dv vector<ld>
#define rall(c) (c).rbegin(), (c).rend()
#define lpr pair<ll, ll>
#define mp make_pair
#define cin(c) \
    ll c;      \
    cin >> c;
#define lmap unordered_map<ll, ll>
#define vinp(a, n) \
    inc(i, 1, n)   \
    {              \
        cin(k);    \
        a.pb(k);   \
    }
#define LIM 1000000007
#define F first
#define S second
#define fr(i, n) inc(i, 0, n - 1)
#define fri(n, a) \
    inc(i, 0, n - 1) { cin >> a[i]; }
//#define end cout<<"\n";
#define debug(p) cout << p;
#define umap unordered_map
#define uset unordered_set
#define fill(a, val, n) \
    inc(i, 0, n - 1) { a[i] = val; }
string binary(ll n)
{
    string s="";
    while(n)
    {
        s=to_string(n%2)+s;
        n/=2;
    }
    ll sz=s.size();
    //cout<<sz;
    inc(i,1,31-sz)
    s="0"+s;
    return s;
}
void i_love_Accepted()
{
    ll n;
    cin>>n;
    ll k;
    vector<string> v;
    string s;
    lmap p;
    fr(i,n)
    {
        cin>>k;
        s=binary(k);
        //cout<<s<<"\n";
        v.pb(s);
        inc(j,0,s.size()-1)
        {
            if(s[j]=='1')
                p[j]++;
        }
    }
    s="";
    ll r;
    inc(i,0,v.size()-1)
    {
        s="";
        inc(j,0,v[i].size()-1)
        {
            r=p[j];
            if(v[i][j]=='1')
            r--;
            if(r%2)
                s.pb('1');
            else
                s.pb('0');
        }
        //ll a=1;
        ll a=stoll(s,nullptr,2);
        cout<<a<<" ";
    }
}   
int main()
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        i_love_Accepted();
        //end;
    } 
}


Measured memory_bytes: 18912
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[1001][1001]={};
char a[1001][1001];
int main(){
	int H,W;
	ll MOD=1e+9+7;
	scan(H);scan(W);
	rep(i,H){
		scan(a[i]);
	}
	dp[0][0]=1;
	rep(i,H){
		rep(j,W){
			if(i!=H-1){
				if(a[i][j]=='.'&&a[i+1][j]=='.'){
					dp[i+1][j]+=dp[i][j];
					dp[i+1][j]%=MOD;
				}
			}
			if(j!=W-1){
				if(a[i][j]=='.'&&a[i][j+1]=='.'){
					dp[i][j+1]+=dp[i][j];
					dp[i][j+1]%=MOD;
				}
			}
		}
	}
	prin(dp[H-1][W-1]);
	return 0;
}


Measured memory_bytes: 9088
#include <iostream>
using namespace std;
  
int main(){
    int a,b,c,x,y,n;
    n=0;
    cin >> a >> b >> c;
    for (x=a;x<=b;x++){
        y= c % x;
        if ( y == 0 ){
            n++;
        }
    }
    cout << n << "\n";
    return 0;
}

Measured memory_bytes: 1168
n = int(input())
h = list(map(int,input().split()))
ans = 1
for i in range(n-1):
    if h[-i-1] < h[-i-2]:
        h[-i-2] -= 1
    if h[-i-1] < h[-i-2]:
        ans = 0
        break
if ans == 1:
    print("Yes")
else:
    print("No")

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

int a[1000010];
int n;
int maxa,mina;
int cnt;

void Init()
{
	cin>>n;
	mina = 100000000, maxa = 0;
	for (int i = 1; i <= n; i++)
	{
		cin>>a[i];
		mina = min(mina, a[i]);
		maxa = max(maxa, a[i]);
	}
}

int main()
{
	Init();
	
	if (maxa > mina + 1)
	{
		puts("No");
		return 0;
	}
	if (maxa == mina)
	{
		if (mina == n - 1)
		{
			puts("Yes");
			return 0;
		}
		puts(((mina << 1) > n) ? "No" : "Yes");
		return 0;
	}
	
	
	for (int i = 1; i <= n; i++)
		if (a[i] == mina) ++cnt;
	
	if (maxa > cnt )
		if ( n - cnt >= 2 * (maxa - cnt)  )
			if (n >= cnt + 2) return 0*puts("Yes");
	
	puts("No");
	
	return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,a,b;
    string s;
    cin>>n>>a>>b>>s;
    lli an=0,bn=0;
    rep(i,n){
        if(s[i]=='c') {out("No");}
        else if(s[i]=='a'){
            if(an+bn<a+b){
                an+=1;
                out("Yes");
            }
            else{
                out("No");
            }
        }
        else if(s[i]=='b'){
            if(an+bn<a+b&&bn<b){
                bn+=1;
                out("Yes");
            }
            else{
                out("No");
            }
        }
    }
}

Measured memory_bytes: 896
/*
	Nishant Singh
	nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "Yes"
#define N "No"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********


// ******** GLOBAL VARIABLES ********

void solve(){
string s;
cin>>s;
for(auto it:s)
{
	if(it=='7')
	{
		cout<<Y<<ln;
		return;
	}
}
cout<<N<<ln;


}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main() {

	int N, M, cnt = 0, ans[100] = { 0 };
	int T[100] = { 0 }, P[100] = { 0 }, X[100] = { 0 };

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

	for (int i = 0; i < M; i++) {
		cin >> P[i] >> X[i];
		cout << cnt +( X[i] - T[P[i]-1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i ++)
 
int main() {
        long long n, p;
        cin >> n >> p;
        vector<long long> a(n);
        int odd = 0, even = 0;
        rep(i, n) { 
                cin >> a[i];
                if (a[i] & 1) odd ++;
                else even ++;
        }
        if (odd == 0) {
                if (p == 1) cout << 0 << endl;
                else {
                        long long ans = 1;
                        rep(i, n) ans *= 2;
                        cout << ans << endl;
                }
        } else {
                long long ans = 1;
                rep(i, n - 1) ans *= 2;
                cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long n,a[200000];
int main() {
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1; i<n; ++i) {
        if(a[i]==a[i-1]) {
            cout<<"NO"<<'\n';
            return 0;
        }
    }
    cout<<"YES"<<'\n';
    return 0;
}

Measured memory_bytes: 1792
n = gets.to_i
 
a = gets.chomp.split(/\s+/).map{|s| s.to_i}
b = gets.chomp.split(/\s+/).map{|s| s.to_i}
 
pa = 0
pb = 0
 
(0...n).each do |i|
  unless (b[i] - a[i]) % 2 == 0
    pb += 1
    b[i] += 1
  end
  if a[i] - b[i] > 0
    pb += a[i] - b[i]
    b[i] = a[i]
  end
end
 
(0...n).each do |i|
  pa += (b[i] - a[i]) / 2
  a[i] = b[i]
end
 
if pa >= pb
  puts("Yes")
else
  puts("No")
end

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

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

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//~ const int mod = (int)1e9 + 7;
const int mod = 998244353;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}




int main(void) 
{	
	ll r, d, x;
	cin>> r >> d >> x;
	ll sol = 0;
	
	rep(i, 1, 10){
		sol = r*x - d;
		x = sol;
		cout<< sol<<endl;
	}
	
	return 0;
} 


Measured memory_bytes: 256
def main():
    from heapq import heappush, heappop
    from collections import defaultdict
    N, *A = map(int, open(0).read().split())
    l = []
    d = defaultdict(int)
    for i, a in enumerate(A):
        d[a] = i+1
    print(d[1], end='')
    for i in range(2, len(A)+1):
        print(' ' + str(d[i]), end='')
if __name__ == "__main__":
    main()

Measured memory_bytes: 20016
/**
 *    author:  math2do
 *    created: 30.08.2020 16:50:37
**/

#include <bits/stdc++.h>

using namespace std;

vector <char> arr = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  string ans;
  while (n > 0) {
    int d = (int) ((n - 1) % 26);
    char ch = arr[d];
    ans += ch;
    n = (n - 1) / 26;
  } 
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
let s=Array(readLine()!.characters)

var i = 0
var fuminikui = 0
for i in 1...s.count {
  if( ( i % 2 ) == 1 ) {
    if( s[i-1] == "L" ) {
      fuminikui = 1
    }
  } else if ( s[i-1] == "R" ) {
    fuminikui = 1
  }
}

if ( fuminikui == 1 ) {
  print( "No" )
} else {
  print( "Yes" )
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<ll> a(51), b(51), c(51), d(51);
vector<int> A(11);
ll res = 0;
ll n, m, q;
void dfs(int index, int num) {
	A[index] = num;
	if (index == n) {
	    //for(int i=1;i<=n;i++) cout<<A[i]<<" ";
	    //cout<<endl;
		ll tmp = 0;
		for(int i=1;i<=q;i++) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				tmp += d[i];
			}
		}
		res = max(res, tmp);
	}
	else {
		for(int i=num;i<=m;i++) {
			dfs(index + 1, i);
		}
	}
}

int main() {
	cin >> n >> m >> q;
	for(int i=1;i<=q;i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	for(int i=1;i<=m;i++) {
		dfs(1, i);
	}
	cout<<res<<endl;
	return(0);
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef int ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
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++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

void solve() {
	int a, b; cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else if (a >= 6) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  unsigned a,b,c;

  cin >> a >> b >> c;

  unsigned first_residue = a%b;
  if (first_residue == c) {
    cout << "YES" << endl;
    return 0;
  }

  unsigned residue = first_residue + 1;
  for (unsigned n = 2; first_residue != residue; ++n) {
    residue =  (n * a) % b;
    if (residue == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  int a[100];
  cin >> n;
  for (int i = 0; i < n ; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);

  int ans = 0;
  int op = 1;
  for(int i = 0;i<n;i++){
    if(a[i] != 0){
      ans += op * a[i];
    }
    op = op * (-1);
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n; scanf("%d", &n);

	vector<string> S(n);

	vector<int> d(6);

	for (int i = 0; i < n; i++)
	{
		cin >> S[i];

		d[S[i].size()]++;
	}

	bool same = true;

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (S[i].size() != S[j].size())
			{
				same = false;
			}
		}
	}

	if (!same)
	{
		vector<int> v;

		for (int i = 0; i < S.size(); i++)
		{
			for (int j = 0; j < S.size(); j++)
			{
				if (i != j)
				{
					v.push_back(stoi(S[i] + S[j]));
				}
			}
		}

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

		printf("%d\n", v[2]);
	}
	else
	{
		sort(S.begin(), S.end());

		if (n == 3)
		{
			printf("%s\n", (S[1] + S[0]).c_str());
		}
		else
		{
			printf("%s\n", (S[0] + S[3]).c_str());
		}
	}

	return 0;
}

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

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef long long ll;
const ll mod = 1000000;

string pat[][4]={
  "0xxxxxxx","","","",
  "110yyyyx","10xxxxxx","","",
  "1110yyyy","10yxxxxx","10xxxxxx","",
  "11110yyy","10yyxxxx","10xxxxxx","10xxxxxx"
};

string in[1000];
ll pow2[1001];
ll countup(int num,int which){
  ll numofx=0,numofy=0,numofy1=0,reqy=0;
  rep(i,num+1){
    int ind=which-num+i;
    rep(j,8){
      if (pat[num][i][j] == '0' && in[ind][j] == '1')return 0;
      if (pat[num][i][j] == '1' && in[ind][j] == '0')return 0;
      if (pat[num][i][j] == 'y'){
	reqy++;
	if (in[ind][j] == 'x')numofy++;
	if (in[ind][j] == '1')numofy1++;
      }
      if (pat[num][i][j] == 'x'){
	if (in[ind][j] == 'x')numofx++;
      }
    }
  }
  ll ret=1;
  if (reqy > 0){
    if (numofy1 > 0)ret=(pow2[numofy])%mod;
    else if (numofy == 0)return 0;
    else {
      ret=(pow2[numofy]+mod-1)%mod;
    }
  }
  ret=(ret*pow2[numofx])%mod;
  return ret;
}

ll dp[1000];
ll solve(int n){
  rep(i,n)dp[i]=0;
  rep(i,n){
    rep(len,4){
      if (i-(len+1) == -1){
	dp[i]=(dp[i]+countup(len,i))%mod;
      }else if (i-(len+1) >= 0){
	dp[i]=(dp[i]+dp[i-(len+1)]*countup(len,i))%mod;
      }
    }
  }
  return dp[n-1];
}

main(){
  pow2[0]=1;
  REP(i,1,1001)pow2[i]=(pow2[i-1]*2)%mod;
  int n;
  while(cin>>n && n){
    rep(i,n)cin>>in[i];
    cout << solve(n) << endl;
  }
  return false;
}

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

int main()
{string S; int K; cin >> S; cin >> K;
 vector<string> vec;
 for(int i = 0; i < S.size(); i ++){
  for(int j = 1; j <= K; j++){
    string substring = S.substr(i,j);
    vec.push_back(substring);}}
 //K以下の長さの部分文字列を、ありうる範囲でとにかくぶっこむ
  sort(vec.begin(),vec.end());
 vec.erase(unique(vec.begin(),vec.end()),vec.end());
 
 cout << vec[K-1] << endl;
 
 return 0;
}

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

signed main(){
	int A, B, C, D;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	if(A + B > C + D){
		printf("Left\n");
	}
	else if(A + B == C + D){
		printf("Balanced\n");
	}
	else{
		printf("Right\n");
	}
	return 0;
}

Measured memory_bytes: 3764
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

import math
N, M = MII_split()
A_list = LII_split()
A_list.sort(reverse=True)
min_vote = math.ceil(sum(A_list) * 0.25 / M)

print('Yes' if len([x for x in A_list if x >= min_vote]) >= M else 'No')

Measured memory_bytes: 3064
from collections import defaultdict

while True:
  time = [ [0 for _ in range(16)] for __ in range(64) ]
  accepted = [ [0 for _ in range(16)] for __ in range(64) ]

  M,T,P,R = map(int, input().split())
  if M==0 and T==0: break

  for i in range(R):
    m,t,p,j = map(int, input().split())
    if j==0:
      accepted[t][p] = 1
      time[t][p] = time[t][p] + m
    else:
      time[t][p] += 20

  score = defaultdict(int)
  for t in range(1,T+1):
    for p in range(1,P+1):
      score[t] +=  accepted[t][p] * 1<<16
      if accepted[t][p]:
        score[t] -= time[t][p]

  mp = defaultdict(list)
  prev = -1
  for k,v in score.items():
    mp[v].append(k)

  output = ""
  for sc,ts in sorted(mp.items(), key=lambda x: x[0], reverse=True):
    output += '='.join(map(str, sorted(ts, reverse=True)))
    output += ','
  else:
    print(output[:-1])

Measured memory_bytes: 8136
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<typename T> void chkmax(T &a, const T &b) { a = a > b ? a : b; }
template<typename T> void chkmin(T &a, const T &b) { a = a < b ? a : b; }

const int MAXN = 100005, MOD = 1e9 + 7;
void add(int &x, int y) { x += y - MOD, x += x >> 31 & MOD; }
int f[MAXN], tran[MAXN][3], suf[3], can[MAXN], n;
char str[MAXN];

int main() {
	scanf("%s", str + 1);
	n = strlen(str + 1);
	for (int i = 1; i <= n; i++)
		str[i] = str[i] - 'a' + 1;
	memset(tran[n + 1], -1, sizeof(tran[n + 1]));
	memset(suf, -1, sizeof(suf));
	for (int i = n; i > 0; i--) {
		int c = str[i], tmp[3] = { suf[(3 - c) % 3], suf[(4 - c) % 3], suf[(5 - c) % 3] };
		tmp[c] = i;
		if (str[i] == str[i + 1]) {
			tran[i][c] = suf[0];
			tran[i][c * 2 % 3] = i + 1;
			tran[i][0] = tmp[0];
		} else {
			tran[i][0] = tran[i + 1][(3 - c) % 3];
			tran[i][1] = tran[i + 1][(4 - c) % 3];
			tran[i][2] = tran[i + 1][(5 - c) % 3];
		}
		memcpy(suf, tmp, sizeof(suf));
		can[i] = (can[i + 1] + c) % 3;
	}
	if (tran[1][can[1]] < 0) return puts("1"), 0;
	f[0] = 1;
	int res = 0;
	for (int i = 0; i < n; i++) if (f[i]) {
		tran[i + 1][str[i + 1]] = i + 1;
		if (~tran[i + 1][1]) add(f[tran[i + 1][1]], f[i]);
		if (~tran[i + 1][2]) add(f[tran[i + 1][2]], f[i]);
		if (!can[i + 2]) add(res, f[i + 1]);
	}
	printf("%d\n", res % MOD);
	return 0;
}

Measured memory_bytes: 2304
#93 B - Iron Bar Cutting WA (hint)
N = int(input())
A = list(map(int,input().split()))

# 差が最小の切れ目を見つける
length = sum(A)
left = 0
dist = 0
mdist = length
midx = 0
for i,a in enumerate(A):
    left += a
    right = length - left
    dist = abs(left - right)
    if dist < mdist:
        mdist = dist
        midx = i
ans = mdist
print(ans)

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

int main(){
    int a;
    while(true){
        cin >> a;
        if(a==0)break;
        int k[a];
        for(int i=0;i<a;i++)cin >> k[i];
        sort(k,k+a);
        int ans=10000000;
        for(int i=0;i<a-1;i++){
            if(k[i+1]-k[i]<ans)ans=k[i+1]-k[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3156
#include <stdio.h>

int main(void) {
  long long int x = 0, k = 0, d = 0;

  scanf("%lld %lld %lld", &x, &k, &d);

  if (x < 0)x *= -1;

  if (d > x/k) {
      k = (k - x / d)%2;
      x %= d;
  }
  else {
      x -= k*d;
      k = 0;
  }
  if (k) {
      x -= d;
      if (x < 0)x *= -1;
  }

  printf("%lld\n", x);

  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vectors<decltype(inner)>(x, inner); }
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    rep(k,n){
        if(a+k*c-(n-1-k)*d <= b && b <= a+k*d-(n-1-k)*c)
            return puts("YES")*0;
    }
    puts("NO");
    
}


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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

int n, m;
int rep[100010];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	string s;
	cin >> s;
	int n = s.size();
	string t = "keyence";
	int k = 0;
	int i;
	for (i = 0; i < 7; ++i)
	{
		if (s[i] != t[k]) break;
		k++;
	}
	if (i == 7) cout << "YES\n";
	else {
		int j = k - 1;
		int temp = 6;
		for (i = n - 1; i > -1; --i)
		{
			if (s[i] != t[temp]) break;
			temp--;
		}
		if (temp <= j) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
/*smile please!*/
#include<bits/stdc++.h>
using namespace std;
#define   int      long long
#define   fast()   ios_base::sync_with_stdio(0);cin.tie(0)
int32_t main()
{int a,b,k,i,g;
 vector<int> v;
 cin>>a>>b>>k;
 g=__gcd(a,b);
 for(i=g;i>=1;--i)
 {if(g%i==0)
  v.push_back(i);
 }
 cout<<v[k-1];
 return 0;
}





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

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

vector<pll> divs(ll n) {
    vector<pll> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ll cnt = 0;
            while (n % i == 0) {
                cnt++;
                n /= i;
            }
            res.push_back({i, cnt});
        }
    }
    if (n > 1)
        res.push_back({n, 1});
    return res;
}

ll power(ll n, ll m) {
    ll res = 1;
    if (m) {
        res = power(n, m / 2);
        res = res * res;
        if (m % 2)
            res *= n;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll n, p;
    cin >> n >> p;
    vector<pll> v = divs(p);
    ll ans = 1;
    for (int i = 0; i < v.size(); i++)
        ans *= power(v[i].first, v[i].second / n);
    cout << ans << "\n";
    return 0;
}

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

int main(){
  string str;
  cin>>str;
  stack <int> stk,sstk,h;
  vector<int> ans;
  int cnt=0,sum=0;
  str+='\\';
  for(int i=0;i<str.size();i++){
    if(str[i]=='\\')stk.push(i);
    if(stk.size()&&str[i]=='/')cnt+=i-stk.top(),stk.pop();
    if(str[i]=='\\'&&cnt){
      sum+=cnt;
      while(h.size()&&h.top()>stk.size())cnt+=sstk.top(),sstk.pop(),h.pop();
      sstk.push(cnt);
      h.push(stk.size());
      cnt=0;
    }
  }

  while(!sstk.empty())ans.push_back(sstk.top()),sstk.pop();
  cout<<sum<<endl;
  cout <<ans.size();
  for(int i=(int)ans.size()-1;i>=0;i--)cout <<" "<<ans[i];
  cout <<endl;
  return 0;
}

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

#define pr16 

#ifdef pr16
  #define pr(x)                 cerr << #x << ": " << x << endl;
  #define pr2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
  #define pr3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
  #define pr4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
  #define pr5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
  #define pr6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
  #define prdd(a,r,c) for(int i=0;i<(r);i++) { for(int j = 0;j<(c);j++) cerr<<a[i][j]<<" "; cerr<<endl; } cerr<<endl;
  #define prc(a) tr(a, it) cerr<<*(it)<<" "; cerr<<endl
  #define pra(a,n) for(int i=0; i<(n); i++) cerr<<((a)[i])<<" "; cerr<<"\n"
  #define prdd(a,r,c) for(int i=0;i<(r);i++) { for(int j = 0;j<(c);j++) cerr<<a[i][j]<<" "; cerr<<endl; } cerr<<endl; 
  #define prddd(a,x,y,z) for(int i=0;i<x;i++) {cerr<<"layer "<<i<<":\n";prdd(a[i],y,z)}
 
#else
  #define pr(x)
  #define pr2(x, y)
  #define pr3(x, y, z)
  #define pr4(a, b, c, d)
  #define pr5(a, b, c, d, e)
  #define pr6(a, b, c, d, e, f)
  #define prc(a)
  #define pra(a,n)
  #define prdd(a, r, c)
  #define prddd(a,x,y,z)
#endif



int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a+n);
  int ans = 0;
  for (int i = 0; i < n; i++)

  for (int j = 0; j < i; j++)
  for (int k = 0; k < j; k++)
    if (a[i] < a[j] + a[k] and a[i] != a[j] and a[j] != a[k])
      ans ++;

  cout<<ans<<"\n";
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}


int main(){
  int n;
  cin >> n;
  vl d(10000010, 1);
  for(int i = 2; i <= n; i++){
    for(int j = 0; j <= n; j += i){
      d[j]++;
    }
  }
  
  ll sum = 0;
  
  rep(i, 1, n+1){
    sum += d[i]*i;
  }
  
  cout << sum << endl;
  
  return 0;
  
}

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

using namespace std;


void solve(){
    int N;
    cin>>N;
    vector <int> dp(3);

    for(int day = 0;day<N;day++){
        vector <int> new_dp(3,0);
        vector <int> c(3);
        for(int i =0;i<3;i++){
            cin>>c[i];
        }
        for(int i = 0;i<3;i++){
            for(int j =0;j<3;j++){
                if(i!=j){
                    new_dp[j] = max(new_dp[j] , dp[i]+c[j]);
                }
            }
        }
        dp = new_dp;

    }
    int k;
    k = max({dp[0],dp[1],dp[2]});
cout<<k<<endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL =long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 9; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[800][800], a[200000], b[200000];
string str, ss;
bool f;
char c[800][800];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<Edge>vec[20000];
vector<edge>ed;
vector<LL>v;
map<string,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	rep(i, 4) {
		cin >> a[i];
	}
	sort(a, a + 4);
	if (a[0] == 1&&a[1] == 4&&a[2] == 7&&a[3] == 9)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    ll money = 1000;
    ll stocks = 0;
    vector<ll>gain;
    cin >> n;
    vector<ll>a(n);
    REP(i,n)cin >> a[i];
    REP(i,n-1){
        int j = i;
        while(a[i]<a[i+1]){
            i++;
        }
        //購入
        stocks += (money/a[j]);
        money -= (money/a[j])*a[j];
        //売却
        money += stocks*=a[i];
        stocks = 0;
        gain.push_back(money);
    }
    SORT(gain);
    reverse(ALL(gain));
    cout << gain[0] << endl;
    return 0;  
}

Measured memory_bytes: 3632