akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int ans=0;
int a[15],top;
int n,m,q;
struct node{
    int a,b,c,d;
}qe[105];
void dfs(int i,int k){
    if(i>n){
        int sum=0;
        for(int j=1;j<=q;j++){
            if(qe[j].c==a[qe[j].b]-a[qe[j].a]) sum+=qe[j].d;
        }
        ans=max(ans,sum);
        return;
    }
    for(int j=k;j<=m;j++) a[++top]=j,dfs(i+1,j),top--;
}

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++) cin>>qe[i].a>>qe[i].b>>qe[i].c>>qe[i].d;
    dfs(1,1);
    cout<<ans;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,A,B,C;
  cin >> A >> B;
  for(int C=1;C<=3;C++){
    if((A*B*C) % 2 == 1){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
  long long a,b;
  cin>>a>>b;
  if(a%3!=0&&(a+b)%3!=0&&b%3!=0){
    cout<<"Impossible"<<endl;
  }
  else{
    cout<<"Possible"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

template <typename T>
struct twodimBIT
{
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3095512#1
// https://www.slideshare.net/hcpc_hokudai/binary-indexed-tree
private:
	vector< vector<T> > array;
	const int n;
	const int m;

public:
	twodimBIT(int _n,int _m):
		array(_n+1,vector<T>(_m+1,0)), n(_n),m(_m){}

	// (1,1) ~ (x,y) ruisekiwa
	T sum(int x,int y) {
		T s = 0;
		for(int i=x;i>0;i-=i&(-i))
			for(int j=y;j>0;j-=j&(-j))
				s += array[i][j];
		return s;
	}

	// [(x1,y1),(x2,y2)] no souwa
	T sum(int x1,int y1,int x2,int y2){
		return sum(x2,y2) - sum(x1-1,y2) - sum(x2,y1-1) + sum(x1-1,y1-1);
	}

	void add(int x,int y,T k) {
		for(int i=x;i<=n;i+=i&(-i))
			for(int j=y;j<=m;j+=j&(-j))
				array[i][j] += k;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,M,Q;
	cin>>N>>M>>Q;
	twodimBIT<int> train(N+6,N+6);
	FOR(i,0,M){
		int l,r;
		cin>>l>>r;
		train.add(l,r,1);
	}
	FOR(i,0,Q){
		int p,q;
		cin>>p>>q;
		cout<<train.sum(p,0,N,q)<<endl;
	}
}

Measured memory_bytes: 1920
S = gets.strip.split(//).collect{|n| n.to_i}

def calc(s)
	if s.length == 0
		return [0, 1]
	elsif s.length == 1
		return [s[0], 1]
	end
	
	sum = 0
	count = 0
	head = 0
	
	s.length.times{
		head = head * 10 + s[0]
		s = s[1..-1]
		tmp_s, tmp_c = calc(s)
		sum += tmp_s + tmp_c * head
		count += tmp_c
	}
	
	[sum, count]
end

puts calc(S)[0]



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

int main(){
  ll mod=1e9+7;
  int n;
  string s;
  string a="abcdefghijklmnopqrstuvwxyz";
  cin>>n>>s;
  ll ans=1;
  ll vec[26]={};
  for(int i=0;i<n;i++){
    for(int j=0;j<26;j++){
      if(s[i]==a[j]){
        vec[j]++;
      }
    }
  }
  for(int i=0;i<26;i++){
    ans*=vec[i]+1;
    ans%=mod;
  }
  cout<<ans-1<<endl;
}

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

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int a = (n + x - 1) / x;
    cout << a * t << endl;
    return 0;
}

Measured memory_bytes: 3580
/*
     _              ,_,
    / \   _ __, ___,| |__   __ _,_ __
   / ^ \ | '_ \/ _ \| '_ \ / _` | /_/
  /-/-\-\|-| |--| |-|-|_)-|-(_|-|-|
 /_/   \_\_| |__| |_|_.__/ \__,_|_|
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(a)       (a).begin(),(a).end()
#define rep(i,a,n)   for(int i=a ; i<n ; i++)
 
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<ll,ll> mii;
typedef map<char,ll> mci;
 
ll gcd(ll a, ll b){
	if(b==0)return a;
	else return gcd(b, a%b);
}

signed main(){
    ios_base :: sync_with_stdio (false);
	cin.tie(NULL);
	// cout << fixed << setprecision(15);
 
	ll TESTS=1; 
	// cin>>TESTS;
	while(TESTS--){
		ll n, w; cin>>n>>w;
		vi wt(n), val(n);
		ll mxval=0;
		rep(i, 0, n){
			cin>>wt[i]>>val[i];
			mxval+=val[i];
		}
		vi dp(mxval+1, INT_MAX);
		dp[0]=0;
		rep(i, 0, n){
			for(int j=mxval; j>=val[i]; j--){
				if(dp[j-val[i]]!=INT_MAX)dp[j]=min(dp[j], dp[j-val[i]]+wt[i]);
			}
		}
		ll ans=0;
		
		rep(i, 1, mxval+1){
			if(dp[i]!=INT_MAX && dp[i]<=w)ans=max(ans, i);
		}
		cout<<ans<<endl;

	}
    return(0);
}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    return x.first>y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}

ll dp[100001][2];
vector<int> g[100001];
void dfs(int node,int p)
{
    ll cnt=1;
    ll cntw=1;
    if(g[node].size()==1 && p!=-1)
    {
        dp[node][0]=1;
        dp[node][1]=1;
        return;
    }
    for(int to: g[node]){
        if(to == p) continue;
        dfs(to,node);
        cnt*=(dp[to][0]+dp[to][1]);
        cnt%=mod;
        cntw*=dp[to][0];
        cntw%=mod;
    }
    dp[node][0]=cnt;
    dp[node][1]=cntw;
}
void solve()
{   
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1,-1);
    cout<<(dp[1][0]+dp[1][1])%mod;


}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 14208
// https://atcoder.jp/contests/dp/tasks/dp_b
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

const int INF = 1e9 + 7;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, 0, N) cin >> h[i];

    vector<int> dp(N, INF);
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i; j <= min(i + K, N-1); j++) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
	int x,y;
	int temp;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0)break;
		
		if(x<y){
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("out.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}
//struct compare
//{
//  bool operator()(const int& l, const int& r)
//  {
//      return l>r;
//  }
//};

bool cmp(int a, int b)
{
    return a<b;
}
int on(int mask,int st)
{
    return mask|(1<<st);
}
int off(int mask,int st)
{
    return mask&(~(1<<st));
}
bool check(int mask,int st)
{
    return mask&(1<<st);
}
ll inf=1e18;
ll mod=1e9+7;
vector<int>G[300000];
ll dp[300000];
int arr[300000];
int n;
ll pow2[300000];
ll fun(int pos)
{
    if(pos==n)
        return 1;
    ll &ret=dp[pos];
    if(ret!=-1)
        return ret;
    ll ans=0;
    ans=fun(pos+1);
    int val=arr[pos];
    int x=lower_bound(G[val].begin(),G[val].end(),pos)-G[val].begin();
//    cout<<pos<<" - "<<x<<endl;
    int c=0;
    for(int i=x+1;i<G[val].size();i++)
    {
        c++;
        ans%=mod;
        ans+=fun(G[val][i]);
        break;
    }
    ans%=mod;
    return ret=ans;
}
int main()
{
//    READ;
    pow2[0]=1;
    for(int i=1;i<=200010;i++)
    {
        pow2[i]=pow2[i-1]*2;
        pow2[i]%=mod;
    }
    mem(dp,-1);
    int x,last=-1;
    int countt=0;
    sf(n);
    for(int i=0;i<n;i++)
    {
        sf(x);
        if(x==last)
            continue;
        last=x;
        arr[countt]=x;
        G[x].pb(countt);
        countt++;
    }
    n=countt;
//    for(int i=0;i<countt;i++)
//        cout<<arr[i]<<" ";
//    cout<<endl;
    cout<<fun(0)<<endl;


}


Measured memory_bytes: 25216
class UnionFind():
    def __init__(self,n):
        self.parent = [-1 for _ in range(n)]

    def size(self,x):
        return -self.parent[self.find(x)]

    def find(self,x):
        if(self.parent[x]<0):
            return x
        else:
            self.parent[x]=self.find(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return False
        if(self.size(x)<self.size(y)):
            self.parent[y]+=self.parent[x]
            self.parent[x]=y
        else:
            self.parent[x]+=self.parent[y]
            self.parent[y]=x
        return True

    def same(self,x,y):
        return self.find(x)==self.find(y)

N,M = [int(x) for x in input().split()]
ab = [[int(x) for x in input().split()]for _ in range(M)]
#%%
di = {}
for i in ab:
    if(i[0] in di):
        di[i[0]].append(i[1])
    else:
        di[i[0]]=[i[1]]
    if(i[1] in di):
        di[i[1]].append(i[0])
    else:
        di[i[1]]=[i[0]]

joint = 0
un = UnionFind(N)
for i in range(N):
    if(i==0): pass
    else:
        flag = True
        if(i+1 in di):
            for j in di[i+1]:
                if(un.find(i-1)==un.find(j-1)):
                    flag = False
        if(flag):
            joint += 1
            un.unite(i-1,i)
print(N-1-joint)


Measured memory_bytes: 41388
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n;
	cin >> n;
	int cnt(0);
	bool ok = false;
	rep(i, n) {
		int d, e;
		cin >> d >> e;
		if (d == e)cnt++;
		else cnt = 0;
		if (cnt >= 3) {
			ok = true;
		}
	}
	if (ok)cout << "Yes";
	else cout << "No";
	
	return 0;
}

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

double ans,now,x;
string s;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x>>s;
        if(s=="JPY")    ans+=x;
        else ans+=x*380000.0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int c1=0,c2=0;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
             c1++;
        }
        else
            {
                c2++;
            }
    }
    if(c1>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    string t;
    cin>>t;
    int res=0;
    rep(i,0,3){
        if(s[i]==t[i])res++;
    }
    cout<<res<<endl;
}

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

using namespace std;

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

    int begin = 0;
    for(int i=0; i<S.size(); i++){
        if(S.at(i) == 'A'){
            begin = i;
            break;
        }
    }
    int end = S.size();
    for(int i=S.size()-1; i>=0; i--){
        if(S.at(i) == 'Z'){
            end = i;
            break;
        }
    }
    cout << end - begin + 1 << endl;
}

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

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

	int ans=0;
	int a,b;
	for(int i=1;i<n-1;i++){
		a=min(p[i], min(p[i+1],p[i-1]));
		b=max(p[i], max(p[i+1],p[i-1]));

		if(p[i]!=a && p[i]!=b)ans++;
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

ll maxn=365;
ll d=0;
ve <ll> c(26);
ve <ve <ll>> v(maxn,ve <ll> (26));
ve <ll> last(26,-1);
ve <ll> assigned(maxn,-2);
ll ini=0;
//ll a[26][365][2];

ll score(){
	ll sats=0;
	FOR(i,0,d){
	FOR(j,0,26){
		sats-=c[j]*(i-last[j]);
	 }
	ll take=assigned[i];
	sats+=v[i][take]+c[take]*(i-last[take]);
	last[take]=i;
	//cout<<sats<<"\n";
}
return sats;
}

pair <ll,ll> fun1(ll da,ll q){

ll x1=-1,x2=d;
FORR(i,da,0)
if(assigned[i]==q){
	x1=i;
	break;
}
FOR(i,da+1,d)
if(assigned[i]==q){
	x2=i;
	break;
}
return make_pair(x1,x2);
}

ll modify(ll da,ll q){
pair <ll,ll> a1=fun1(da,assigned[da]);
pair <ll,ll> a2=fun1(da,q);
ll z=ini;
ll f=assigned[da];
z-=v[da][f];
z-=c[f]*(da-a1.F)*(a1.S-da);
z+=v[da][q];
z+=c[q]*(da-a2.F)*(a2.S-da);
return z;
}

void change(ll da,ll q){
 	assigned[da]=q;
}





int main(){

	

    FAST
//	PRECISE


cin>>d;
FOR(i,0,26)
cin>>c[i];

FOR(i,0,d)
	FOR(j,0,26)
		cin>>v[i][j];

ve <ll> dummy(d);
FOR(i,0,d){
dummy[i]=rand()%26;
}
assigned=dummy;
ini=score();

ll it=1000000;
while(it>0){
	it--;
	ll x1=rand()%d;
	ll x2=rand()%26;
	ll z=modify(x1,x2);
	if(z>ini){
		ini=z;
		change(x1,x2);
	}
}

FOR(i,0,d)
cout<<assigned[i]+1<<"\n";




return 0;
 }

Measured memory_bytes: 3756
N = int(input())
c = 0
f = 0
for i in range(N):
  a, b = map(int, input().split())
  if a == b:
    c += 1
  else:
    c = 0
  if c == 3:
    f = 1
if f == 0:
  print("No")
else:
  print("Yes")

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

using namespace std;

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector< vector<int> > hyou(h, vector<int>(w, 1));
	int x, y, a;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> a;
		if (a == 1) {
			for (int j = 0; j < h; j++) {
				for (int k = 0; k < x; k++) {
					hyou[j][k] = 0;
				}
			}
		} else if (a == 2) {
			for (int j = 0; j < h; j++) {
				for (int k = x; k < w; k++) {
					hyou[j][k] = 0;
				}
			}
		} else if (a == 3) {
			for (int j = 0; j < y; j++) {
				for (int k = 0; k < w; k++) {
					hyou[j][k] = 0;
				}
			}
		} else {
			for (int j = y; j < h; j++) {
				for (int k = 0; k < w; k++) {
					hyou[j][k] = 0;
				}
			}
		}
	}
	int c = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			c += hyou[i][j];
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
Z = list(map(int, input().split()))
K=Z[-1]
A=Z[0]
B=Z[1]
C=Z[2]
k=K
ans=0
if k>A+B:
  ans=A*2-K+B
elif k>=A:
  ans=A
else:
  ans=k
  
print(ans)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,D,A;
    Scd3(N,D,A);
    vii h(N);
    int X,H;
    Rep(i,N){
        Scd2(X,H);
        h[i] = {X,H};
    }
    sort( h.begin(), h.end() );

    vl s(N+1);
    s[0] = h[0].second;
    Rep(i,N-1){
        s[i+1] = h[i+1].second - h[i].second;
    }

    ll l = 0;
    ll r = 0;
    ll bomb = 0;
    ll ans = 0;
    Rep(i,N){
        l = i;
        while( r < N && h[r].first <= h[l].first+2*D ){
            r++;
        }

        bomb = max( (s[i]+A-1)/A, 0ll );
        ans += bomb;
        s[l] -= bomb*A;
        s[r] += bomb*A;
        s[l+1] += s[l];
    }

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

    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
	int n,m,oi=0;
	cin>>n>>m;
	int a[m+1];
	for(int i=1;i<=m;i++){
		cin>>a[i];
		oi+=a[i];
	}
	int sp=n-oi;
	if(sp>=0) cout<<sp<<endl;
	else cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    A, B = LI()
    ans = (A + B) % 24
    return ans

print(main())

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

vector<char> hands = {'p', 's', 'r'};

int main() {
	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	string t; cin >> t;
	int ans = 0;
	vector<int> point = {p, s, r};
	vector<char> v(n);
	for (int i = 0; i < n; i++) {
		char prev = 'q';
		if (i >= k) prev = v.at(i - k);
		for (int j = 0; j < 3; j++) {
			if (hands.at(j) != t.at(i)) continue;
			int k = (j + 1) % 3;
			if (prev != hands.at(k)) {
				v.at(i) = hands.at(k);
				ans += point.at(k);
			} else v.at(i) = 'q';
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAX1 100000
#define MAX2 50000
int binarySearch(int,int);
int a[MAX1];
int main()
{
  int n,q,i,b[MAX2],x,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&b[i]);
    }

  for(i=0;i<q;i++)
    {
      x=binarySearch(b[i],n);
      if(x==1)
        {
          count=count+1;
        }
    }
  printf("%d\n",count);
  return 0;
}

int binarySearch(int key,int n)
{
  int left=0,right=n,mid;
  while(left<right)
    {
      mid=(left+right)/2;
      if(a[mid]==key)
        {
          return 1;
        }
      else if(key<a[mid])
        right=mid;
      else left=mid+1;
    }
  return 0;
}

Measured memory_bytes: 1180
import java.lang.reflect.Array;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String S = sc.next();
		String ans = "";
		if (!S.substring(0,1).equals("A")) {
			System.out.println("WA");
			return;
		}
		int C = 0;
		for (int i = 2; i < S.length()-1; i++) {
			if(S.charAt(i) == 'C'){
				C++;
			}
		}
		if(C!=1){
			System.out.println("WA");
			return;
		}
		if (ans.equals("wa")) {
			return;
		}
		String s = S.substring(1,S.length()).replace('C', 'c');
		if(!s.equals(s.toLowerCase())){
			System.out.println("WA");
			return;
		}
		System.out.println("AC");
	}	
}


Measured memory_bytes: 21972
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int k, s;
	cin >> k >> s;
	LL ans = 0;
	for(int x = max(s - 2 * k, 0); x <= k && x <= s; ++x){
		int miny = max(s - x - k, 0);
		int maxy = min(s - x, k);
		ans += maxy - miny + 1;
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
n = int(input())
s = list(input())
stack = []


for v in s:
    if stack and stack[-1] == "(" and v == ")":
        stack.pop()
    else:
        stack.append(v)


for v in stack:
    if v == ")":
        s.insert(0, "(")
    else:
        s.append(")")

print("".join(s))



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

int main(){
  long long x, a, b;
  cin >> x;

  for(int i=0;i<1000;i++){
    for(int j=-1000;j<1000;j++){
      if(pow(i, 5)-pow(j, 5)==x){
        a=i;b=j;break;
      }
    }
  }

  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 4060
let h = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let swap i j t = let tmp = t.(i) in t.(i) <- t.(j); t.(j) <- tmp

let extract (t : int array) =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !h && t.(l) > t.(i) then l else i in
    let m = if r <= !h && t.(r) > t.(m) then r else m in
    if i <> m then begin
      swap i m t;
      max_heapify m
    end in
  let ret = t.(1) in
  t.(1) <- t.(!h);
  decr h;
  max_heapify 1;
  ret

let insert x (t : int array) =
  let rec doit i =
    if i > 1 && t.(parent i) < t.(i) then begin
      swap i (parent i) t;
      doit (parent i)
    end in
  incr h;
  t.(!h) <- x;
  doit !h

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let () =
  let t = Array.make 2000001 0 in
  let rec doit () =
    match split (read_line ()) ' ' with
    | ["extract"] -> Printf.printf "%d\n%!" (extract t); doit ()
    | ["insert"; n] -> insert (int_of_string n) t; doit ()
    | _ -> () in
  doit ()

Measured memory_bytes: 20328
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 107, K = 1e5 + 7, inf = 1e18;
int n, s, w[N], v[N], dp[N][K], sum;

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> s;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= sum; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= v[i]) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    int res = 0;
    for (int j = 0; j <= sum; j++) {
        if (dp[n][j] <= s) {
            res = max(res, j);
        }
    }
    cout << res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 83968
#include <bits/stdc++.h>
using namespace std;
int n, a[1000000], tot=0;
int main(){
	scanf("%d", &n);
	for (register int i=1; i<n; i++)
		for (register int j=i; j<n; j+=i) a[j]++;
	for (register int i=1; i<n; i++) tot+=a[i];
	printf("%d\n", tot); 
	return 0;
}

Measured memory_bytes: 7616
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return;
            }
        } 
    }

    cout << "APPROVED" << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
    int n,k;
    cin>>n>>k;
    if(k==1){
        cout<<0<<endl;
    }
    else{
        cout<<n-k<<endl;
    }
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0;
    for (int i = min(A, B); i >= 1; --i) {
        if (A % i == 0 && B % i == 0) {
            --K;
        }
        if (K == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s.at(2)==s.at(3) and s.at(4)==s.at(5)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a;
    int b;
    cin >> a >> b;
    int c;
    int d;
    double f;
    c = a / b;
    d = a % b;
    f = 1.0 * a / (1.0 * b);
    printf("%d %d %.8lf\n",c,d,f);
}


Measured memory_bytes: 3204
#include <iostream>

using namespace std;

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

  long long sum = 0;
  for (int i = 1; i < n + 1; i++) {
    if (!(i % 15 == 0 || i % 5 == 0 || i % 3 == 0)) sum += i;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

int main() {
	int n, m, a[100010], ans = 0;
	cin >> n >> m;
	fill(a, a + n + 1, 1);
	bool b[100010];
	fill(b, b + n + 1, false);
	b[1] = true;
	for (int i = 0;i < m;i++) {
		int x, y;
		cin >> x >> y;
		if (a[x] == 1&&b[x]) {
			a[x] = 0;
			b[x] = false;
			a[y]++;
			b[y] = true;
		}
		else if (a[x] != 1 && b[x]) {
			a[x]--;
			a[y]++;
			b[y] = true;
		}
		else  {
			a[x]--;
			a[y]++;
		}
	}
	for (int i = 1;i <= n;i++) {
		if (b[i])ans++;
	}
	cout << ans << endl;
	}

Measured memory_bytes: 768
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    System.out.println(calc(sc.nextLong(),2)-1);
    
  }
  
  public static long calc(long x,long sum){
    return x == 1 ? sum : calc(x/2,sum * 2);
}
}

Measured memory_bytes: 23124
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100005;
struct node{int x,y,num;}p[N];
struct edge{int x,y,l;}eg[N*3];
int fa[N];
inline bool cmpx(node a,node b) {return a.x<b.x;}
inline bool cmpy(node a,node b) {return a.y<b.y;}
inline bool cmpl(edge a,edge b) {return a.l<b.l;}
inline int getf(int x) {
	if(fa[x]==x) return x;
	fa[x]=getf(fa[x]);
	return fa[x];
}
int main() {
	int n,tot=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d",&p[i].x,&p[i].y);
		p[i].num=i;
		fa[i]=i;
	}
	sort(p+1,p+n+1,cmpx);
	for(int i=1;i<n;i++) eg[++tot]=(edge){p[i].num,p[i+1].num,(p[i+1].x-p[i].x)};
	sort(p+1,p+n+1,cmpy);
	for(int i=1;i<n;i++) eg[++tot]=(edge){p[i].num,p[i+1].num,(p[i+1].y-p[i].y)};
	sort(eg+1,eg+tot+1,cmpl);
	int a,b,ct=0,ans=0;
	for(int i=1;i<=tot;i++) {
		a=getf(eg[i].x);
		b=getf(eg[i].y);
		if(a==b) continue;
		ct++;
		ans+=eg[i].l;
		fa[a]=b;
		if(ct==n-1) break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5376
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	VI C(N);
	for (int n = 0; n < N; n++)cin >> C[n];
	VLL DP(N, 0);
	VLL DPC(2 * 1e5+1, 0);
	DP[0] = 0;
	LL sum = 0;
	DPC[C[0]] = 1;
	for (int n = 1; n < N; n++) {
		if (C[n] == C[n - 1])continue;
		DP[n] = DPC[C[n]];
		DPC[C[n]] += sum+1;
		DPC[C[n]] %= MOD;
		sum += DP[n];
		sum %= MOD;
	}
	LL ans = 0;
	for (int n = 0; n < N; n++) {
		ans += DP[n];
		ans %= MOD;
	}
	cout << (ans + 1)%MOD << "\n";
	return 0;
}


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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[500000] = {}, B[500000] = {}, weight[1000] = {}, value[1000] = {};
ll dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, aka = 0, kaijou = 1, e = 0, f = 0, n = 0, su = 0, ma = INF, mi = -1;
double ans;
str S;
pair<str, ll> Sp[1000];
bool an = true, bn = false;
long long mod = 1e9 + 7;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	for (int i = 0; i < n; i++) {
		if (B[i] > mi) {
			mi = B[i];
			a = i;
		}
	}
	B[a] = 0;
	b = mi;
	mi = 0;
	for (int i = 0; i < n; i++) {
		if (B[i] >= mi) {
			mi = B[i];
		}
	}
	for (int i = 0; i < n; i++) {
		if (a == i)cout << mi << endl;
		else cout << b << endl;
	}
	
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

ll A[1000][1000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    vector<ll> v,w;
    vector<ll> :: iterator itrv;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n>>m>>a>>b;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(i<b){
                A[i][j]=0;
            }
            else{
                A[i][j]=1;
            }
        }
    }
    for(j=0;j<a;j++){
        for(i=0;i<n;i++){
            A[i][j]^=1;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cout<<A[i][j];
        }
        cout<<"\n";
    }
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


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

int main(){
	int w,n,ans[31],a,b,i;
	cin>>w>>n;
	for(i = 1;i <= w;i++){
		ans[i-1] = i;
	}
	for(i = 1;i <= n;i++){
		scanf("%d,%d",&a,&b);
		swap(ans[a-1],ans[b-1]);
	}
	for(i = 0;i < w;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

vector<long long> lucasnum(100,-1);

long long lucas(int i){
	if(lucasnum[i]!=-1){
		return lucasnum[i];
	}
	return lucasnum[i]= lucas(i - 1) + lucas(i - 2);
}

int main()
{
	int n;
	cin >> n;
	lucasnum[0] = 2;
	lucasnum[1] = 1;
	cout << lucas(n) << endl;
}


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

ll a,b,c,n,m;
ll ans=100000000000;

string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin>>a;
  double PI=3.14159265358979323846;
  cout<<a*PI*2;
  

  return 0;
}



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

int main(int argc, char **argv) {
  long N;
  cin >> N;

  long I = 0;
  for (long i = 1; (i * i) <= N; i++) {
    if (N % i == 0) {
      I = i;
    }
  }

  long ans = (I - 1) + (N / I - 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	hs := make([]int64, N+1)
	for i := 0; i < N; i++ {
		hs[i] = nextInt64()
	}
	hs[N] = 10000000000
	start := 0
	ans := 0
	for {
		if start == N {
			break
		}
		count := 0
		for i := start; i < N+1; i++ {
			if hs[i] >= hs[i+1] {
				count += 1
			} else {
				if count > ans {
					ans = count
				}
				start = i + 1
				break
			}
		}
	}
	fmt.Println(ans)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 3072
s=input()
str1="keyence"
count=0
num=len(s)
if s==str1:
    yn=0
elif s[:7]==str1:
    yn=0
elif s[num-8:]==str1:
    yn=0
else:
    for i in range(7):
        if str1[i]==s[i]:
            count+=1
        else:
            break
    if s[num-7+count:]==str1[count:]:
        yn=0
    else:
        yn=1
if yn==0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int h[n];
	int i,j;
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	int ans = 1;
	int flag;
	for(i=1;i<n;i++){
		flag = 0;
		for(j=0;j<i;j++){
			if(h[i]<h[j]){
				flag = 1;
			}
		}
		if(flag==0){
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>

#define Maxn 200010
#define LL long long

using namespace std;

inline LL read() {
    LL x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

LL n, a[Maxn];

map <LL, LL> vis;

int main() {
    n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    LL ans = 0;
    for(int i = n; i; --i) {
        ans += vis[i + a[i]];
        ++vis[i - a[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27892
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>

#include <set>
#include <list>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>

#include <algorithm>
#include <utility>

using namespace std;
namespace patch
{
    template <typename T>
    string to_string(const T& n)
    {
        ostringstream stm;
        stm << n;
        return stm.str();
    }
    int stoi(string str)
    {
        int ret;
        istringstream stm(str);
        stm >> ret;
        if (stm.fail())
        {
            throw -1;
        }
        return ret; 
    }
    vector<string> split(const string &str)
    {
        istringstream stm(str);
        vector<string> ret;
        copy(istream_iterator<string>(stm),
            istream_iterator<string>(),
            back_inserter(ret));
        return ret;
    }
    vector<string> split(const string &str, char delim)
    {
        istringstream stm(str);
        vector<string> ret;
        string buf;
        while (getline(stm, buf, delim))
        {
            ret.push_back(buf);
        }
        return ret;
    }
}

int bubbleSort(vector<int>& vs)
{
    int end = vs.size();
    if (end == 1)
    {
        return 0;
    }
    int cnt = 0;
    for (int j = 0; j < end - 1; ++j)
    {
        for (int i = 0; i < end - j - 1; ++i)
        {
            if (vs[i] > vs[i+1])
            {
                swap(vs[i], vs[i+1]);
                ++cnt;
            }
        }
    } 
    return cnt;
}

// bubble sort
int main()
{
    ios::sync_with_stdio(false);

    // line 1
    string s1;
    getline(cin, s1);
    int n = patch::stoi(s1);

    // line 2
    vector<int> vs(n);
    vector<string> ss;
    string s2;
    getline(cin, s2);
    ss = patch::split(s2);
    for (int n = 0, sz = ss.size(); n < sz; ++n)
    {
        vs[n] = patch::stoi(ss[n]);
    }

    int cnt = bubbleSort(vs);
    
    bool isFirst = true;
    for (int n : vs)
    {
        //cout << n << " ";
        if (isFirst)
        {
            cout << n;
            isFirst = false;
        }
        else
        {
            cout << " " << n;
        }
    }
    cout << "\n";
    cout << cnt << "\n";
    
    
    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

struct Point {
  int64_t x, y;
  Point(int64_t x = 0, int64_t y = 0) : x(x), y(y) {}
};

istream& operator>>(istream &is, Point &p)
{
  is >> p.x >> p.y;
  return is;
}

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

  vector<Point> p(N);
  cin >> p;

  int64_t z_max = -1e+12, z_min = 1e+12;
  int64_t w_max = -1e+12, w_min = 1e+12;
  N_TIMES(n, N) {
    int64_t z = p[n].x + p[n].y, w = p[n].x - p[n].y;
    z_max = max(z_max, z); z_min = min(z_min, z);
    w_max = max(w_max, w); w_min = min(w_min, w);
  }

  cout << max(z_max - z_min, w_max - w_min) << endl;

  return 0;
}

Measured memory_bytes: 6340