akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

int n;
string s;
int main() {
	int i;
	cin >> s;
	n = s.size();
	for(i=0; i<n && s[i]!='C'; i++);
	for(; i<n && s[i]!='F'; i++);
	puts(i<n ? "Yes" : "No");
	return 0;
}

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

using namespace std;

int N;
int F[100][14];
int P[100][15];

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

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            scanf("%d", &F[i][j]);
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            scanf("%d", &P[i][j]);
        }
    }

    int res = -(1 << 30);

    for(int b = 1; b < (1<<10); b++){
        int cc = 0;
        for(int i = 0; i < N; i++){
            int c = 0;
            for(int j = 0; j < 10; j++){
                if( (b>>j & 1) && F[i][j] ) c++;
                
            }
            cc += P[i][c];
            
        }
        if(res < cc) res = cc;
    }

    printf("%d\n", res);

    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << ((a + b > c + d) ? "Left" : (a + b == c + d) ? "Balanced" : "Right") << '\n';

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<Int> l(n);
    rep(i,n) cin>>l[i];
    Int ans=0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++ ){
                if(l[i]+l[j]>l[k])
                {
                    if(l[i]+l[k]>l[j])
                    {
                        if(l[j]+l[k]>l[i])
                        {
                           if((l[i]!=l[j])&&(l[i]!=l[k])&&(l[j]!=l[k])) ans++;
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define MOD 1000000007
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int dp_blue[2001][2001];
int dp_red[2001][2001];
int main(){
    std::ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int cnt_blue = k;
    int cnt_red = n - k;

    // dp for blue
    dp_blue[1][1] = 1;

    for(int i=1;i<cnt_blue;++i)
    {
        for(int j=0;j<=cnt_blue;++j)
        {
            dp_blue[i+1][j] += dp_blue[i][j] % MOD; // add to an existing group
            dp_blue[i+1][j] %= MOD;
            dp_blue[i+1][j+1] += dp_blue[i][j] % MOD; // create a new group
            dp_blue[i+1][j+1] %= MOD;
        }
    }

    // dp for red
    dp_red[1][1] = 1;
    if(n==k)
    {
        dp_red[0][0] = 1;
    }
    for(int i=1;i<cnt_red;++i)
    {
        for(int j=0;j<=cnt_red;++j)
        {
            dp_red[i+1][j] += dp_red[i][j] % MOD; // add to an existing group
            dp_red[i+1][j] %= MOD;
            dp_red[i+1][j+1] += dp_red[i][j] % MOD; // create a new group
            dp_red[i+1][j+1] %= MOD;
        }
    }

    for(int i=1;i<=k;++i)
    {
        ll ret = 0;
        ll blue_ptn = dp_blue[k][i];
        ll red_minus1 = (blue_ptn * dp_red[n-k][i-1]) % MOD;
        ll red_same = (blue_ptn * dp_red[n-k][i] * 2) % MOD;
        ll red_plus1 = (blue_ptn * dp_red[n-k][i+1]) % MOD;
        ret = (red_minus1 + red_same + red_plus1) % MOD;
        cout << ret << endl;
    }
}

Measured memory_bytes: 18688
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int sex[1010]; // male 0 female 1
int read(){
	char c = getchar();
	int res = 0,flag = 0;
	while((c<'0'||c>'9')&&c!='-')
		c = getchar();
	if(c=='-'){
		flag = 1; c = getchar();
	}
	while(c>='0'&&c<='9'){
		res = res*10+c-'0';
		c = getchar();
	}
	if(flag) sex[res] = 1;
	return res;
}

int main(){
	int n;
	cin >> n;
	int a = n%10, b = (n/10)%10 ,c = n/100;
	if(a==7||b==7||c==7) cout << "Yes" << endl;
	else cout << "No" << endl; 
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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




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



int n,m; cin>>n>>m;
vector<pii>v(m);
for(int i=0;i<m;i++)
{
  cin>>v[i].first>>v[i].second;
  v[i].first--;
}

for(int i=0;i<pow(10,n);i++)
{
  vector<int>d;
  int x=i;
  while(x)
  {
    d.push_back(x%10);
    x/=10;
  }
  if(d.size()==0)
  d.push_back(0);
   if(d.size()<n)continue;
  reverse(d.begin(),d.end());
  bool check=1;
  for(int i=0;i<m;i++)
  {
    if(d[v[i].first]!=v[i].second)
    {
      check=0; break;
    }
  }
  if(check)
  {
    for(auto i : d)cout<<i;
     return 0;
  }
}


cout<<-1;



  
}



Measured memory_bytes: 256
use proconio::marker::Usize1;
use proconio::*;

fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    input! {
        t: [Usize1; d],
    };

    // println!("{}", calc_score(d, &c, &s, &t));
    calc_score(d, &c, &s, &t);
}

fn calc_score(d: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, t: &Vec<usize>) {
    let mut res = 0;
    let mut lasts = [-1; 26];

    for i in 0..d {
        res += s[i][t[i]];
        lasts[t[i]] = i as i64;

        for j in 0..26 {
            let i = i as i64;
            let last = lasts[j];
            res -= c[j] * (i - last);
        }

        println!("{}", res);
    }
}


Measured memory_bytes: 2300
#include <stdio.h>

int main (void){

	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	int h, w;
	scanf("%d", &h);
	scanf("%d", &w);

	int ans = 0;

	ans = (H - h) * (W - w);

	printf("%d\n", ans);
	return 0;

}


Measured memory_bytes: 128
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    d = collections.defaultdict(int)
    for i in range(n):
        if 1 <= a[i] <= 399:
            d[0] += 1
        elif 400 <= a[i] <= 799:
            d[1] += 1
        elif 800 <= a[i] <= 1199:
            d[2] += 1
        elif 1200 <= a[i] <= 1599:
            d[3] += 1
        elif 1600 <= a[i] <= 1999:
            d[4] += 1
        elif 2000 <= a[i] <= 2399:
            d[5] += 1
        elif 2400 <= a[i] <= 2799:
            d[6] += 1
        elif 2800 <= a[i] <= 3199:
            d[7] += 1
        else:
            d[8] += 1
    print(len(d) if 8 not in d else 1 if len(d) == 1 else len(d) - 1, len(d) if 8 not in d else len(d) + d[8] - 1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main()
{
 
 
int t;cin>>t; 
if(t%10==3)
{
    cout<<"bon";
}else if(t%10==0||t%10==1||t%10==6||t%10==8)
{
    cout<<"pon";
}else
{
     cout<<"hon";
}

 
return 0;
   
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#define IL inline
#define RG register
#define inf 0x3f3f3f3f
#define LL long long
#define N 10005
#define M 20005
using namespace std;
IL int gi()
{
	RG int res=0,s=1;RG char ch;
	for(ch=getchar(); (ch<'0'||ch>'9')&&ch!='-' ;ch=getchar());
	if(ch=='-') s=-1,ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
	return res*s;
}
int n,m,head[N],edge[2*M][5],num=-1;
int dis[N],flag[N],ans=0,a[N];
struct node
{
	int d,v;
	node(RG int dd=0,RG int vv=0){d=dd,v=vv;}
	bool operator < (const node &o) const{
		return v>o.v;
	}
};
priority_queue<node>heap;
IL void adde(RG int u,RG int v,RG int d,RG int c)
{
	edge[++num][0]=v;edge[num][1]=head[u];head[u]=num;edge[num][2]=d,edge[num][3]=c,edge[num][4]=0;
	edge[++num][0]=u;edge[num][1]=head[v];head[v]=num;edge[num][2]=d,edge[num][3]=c,edge[num][4]=0;
}
IL void init(){
	memset(head,-1,sizeof(head)); num=-1; ans=0;
	memset(dis,inf,sizeof(dis));
	memset(flag,0,sizeof(flag));
}
IL int cmp(RG int x,RG int y){return dis[x]<dis[y];}
IL void work1()
{
	RG int p;
	dis[1]=0; heap.push(node(1,0));
	while(!heap.empty())
		{
			p=heap.top().d; heap.pop();
			while(flag[p]&&!heap.empty()) p=heap.top().d,heap.pop();
			if(flag[p]) break; flag[p]=1;
			for(RG int i=head[p];i!=-1;i=edge[i][1]){
				if(dis[edge[i][0]]>dis[p]+edge[i][2]){
					dis[edge[i][0]]=dis[p]+edge[i][2];
					heap.push(node(edge[i][0],dis[edge[i][0]]));
				}
			}
		}
	RG int mn;
	for(RG int i=1;i<=n;++i) a[i]=i;
	sort(a+1,a+n+1,cmp);
	for(RG int i=2;i<=n;++i)
		{
			mn=inf;
			for(RG int j=head[i];j!=-1;j=edge[j][1])
				{
					if(dis[i]==dis[edge[j][0]]+edge[j][2])
						mn=min(mn,edge[j][3]);
				}
			ans+=mn;
		}
	printf("%d\n",ans);
}
int main()
{
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	RG int u,v,d,c;
	while(true)
		{
			n=gi(),m=gi(); if(!n&&!m) break; init();
			for(RG int i=1;i<=m;++i)
				u=gi(),v=gi(),d=gi(),c=gi(),adde(u,v,d,c);
			work1();
		}
	//fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 4320
#include <stdio.h>
int main()
{
 int cd,cr,i,j;
 while(1)
 {
  scanf("%d %d", &cd ,&cr);
  if(cd==0 && cr==0)
   return 0;

  for(i=0; i < cd; i++)
  {
    for(j=0;j < cr; j++)
       printf("#");
    printf("\n");
  }
  printf("\n");
 }
 return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string S;
	cin >> S;
	string ex = "YAKI";
	if (S.size() < 4) {
		cout << "No" << endl;
	}
	else {
		if (S.substr(0, 4) == ex) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int a,b;
  cin>>a>>b;
  if(a+b==15)
    {
      cout<<"+"<<endl;
    }
  else if((a*b)==15)
    {
      cout<<"*"<<endl;
    }
  else
    cout<<"x"<<endl;
  return 0 ;
}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    int a[100010];
    int sm=0;
    cin>>n;
    f(n){
        cin>>a[i];
        if(i>0){
            sm+=abs(a[i]-a[i-1]);
        }

    }
    int be=abs(a[0]);
    int en=abs(a[n-1]);
    int e1=sm-abs(a[0]-a[1])+en+abs(a[1]);
    int e2=sm-abs(a[n-1]-a[n-2])+abs(a[n-2])+be;
    //cout<<sm<<" "<<be<<" "<<en<<endl;

    f(n){
        if(i==0){
            cout<<e1<<endl;
            continue;
        }
        if(i==n-1){
            cout<<e2<<endl;
            continue;
        }
        auto ans=sm;
        ans-=abs(a[i]-a[i-1]);
        if(i<n-1){
            ans-=abs(a[i]-a[i+1]);
            ans+=abs(a[i-1]-a[i+1]);
        }
        ans+=be;
        ans+=en;
        cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 1664
n=int(input())
d=[list(map(int,input().split())) for _ in range(n)]

cnt=0

for i in range(n):
    if d[i][0]==d[i][1]:
        cnt+=1
        if cnt>=3:
            print('Yes')
            exit(0)
    else:
        cnt=0

print('No')

Measured memory_bytes: 62488
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int dp[100001][9][9][2];

int main(){
	string str;
	while(cin >> str){
		int s = str.size();
		if(str[0] == '#') break;
		rep(i,s+1){
			for(int j = 0; j < 9; j++){
				for(int k = 0; k < 9; k++){
					dp[i][j][k][0] = INF;
					dp[i][j][k][1] = INF;
				}
			}
		}
		for(int j = 0; j < 9; j++){
			for(int k = 0; k < 9; k++){
				if(j%3 > k%3) continue;
				dp[0][j][k][0] = 0;
				dp[0][j][k][1] = 0;
			}
		}
		for(int i = 1; i <= s; i++){
			int n = str[i-1]-'1';
			rep(j,9) rep(k,9){
				if(n%3 <= k%3) dp[i][n][k][0] = min(dp[i][n][k][0],min(dp[i-1][j][k][0]+1,dp[i-1][j][k][1]));
				if(j%3 <= n%3) dp[i][j][n][1] = min(dp[i][j][n][1],min(dp[i-1][j][k][0],dp[i-1][j][k][1]+1));
			}
		}
		int ans = INF;
		rep(j,9) rep(k,9) rep(l,2){
			ans = min(ans,dp[s][j][k][l]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 64588
#include<cstdio>
int l[300005], r[300005];
int a[300005];
int fix[300005];
const long long mod = 998244353;

long long getF(long long n){
    long long res = 1;
    for(long long i = 2; i <= n; i++) res = res*i%mod;
    return res;
}

int getLength(int l,int r,int n){
    if(r>=l) return r-l+1;
    else return n-l+1+r;
}

int stdForm(int u,int n){
    if(u<1) u += n;
    if(u>n) u -= n;
    return u;
}


int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    int p = 1, ok = 1;
    int cnt = 0;
    while(p<=n){
        int np = p, u = a[p];
        while(np+1<=n && a[np+1]==u) np++;
        if(l[u]!=0){
            if(l[u]==1 && np==n)l[u] = p;
            else ok = 0;
        }
        else{
            cnt++;
            l[u] = p, r[u] = np;
        }
        p = np+1;
    }
    if(!ok) printf("0\n");
    else{
        int t = getLength(l[1],r[1],n);
        if(t==n) printf("%lld\n",getF(n));
        else{
            long long ans = 1, blank = 0;
            for(int i = 1; i <= n; i++){
                if(l[i]==0){
                    if(blank==0){
                        ans = 0;
                        break;
                    }
                    else{
                        ans = ans*blank%mod;
                        blank--;
                    }
                }
                else{
                    cnt--;
                    if(getLength(l[i],r[i],n)>t){
                        ans = 0;
                        break;
                    }
                    int left = stdForm(l[i]-1,n), right = stdForm(r[i]+1,n);
                    if(a[left]>i && a[right]>i){ 
                        if(getLength(l[i],r[i],n)!=t){
                            ans = 0;
                            break;
                        }
                        else fix[i] = l[i];
                    }
                    else if(a[left]<i && a[right]<i){
                        int minn = stdForm(r[i]-t+1,n), maxn = stdForm(l[i],n);
                        ans = ans*(long long)getLength(minn,maxn,n)%mod;
                        int next = stdForm(fix[a[left]]+1,n);
                        blank += getLength(next,r[i],n)-1;
                    }
                    else if(a[left]<i){
                        fix[i] = stdForm(r[i]-t+1,n);
                        int next = stdForm(fix[a[left]]+1,n);
                        int upper = stdForm(fix[i]-1,n);
                        if(next!=fix[i]) blank += getLength(next,upper,n);
                    }
                    else{
                        fix[i] = l[i];
                        int next = stdForm(fix[i]+1,n), upper = stdForm(fix[a[right]]-1,n);
                        if(next!=stdForm(fix[a[right]],n)) blank += getLength(next,upper,n);
                    }
                    //makeGood(l[i],r[i],n);
                    if(cnt==0){
                        long long mul = getF(n-i);
                        ans = ans*mul%mod;
                        break;
                    }
                }
                
            }
            printf("%lld\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 6376
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}

const o = new AtCoder()
let n=o.n(),arr=[],c=new Array(n)
for(let i=0;i<n;i++)arr.push(o.n())
let now=arr[0]
c[0] = 0;
c[1] = o.abs(arr[1] - arr[0]);
for(let i=1;i<n;i++){
  c[i+1] = o.min(c[i-1] + o.abs(arr[i+1] - arr[i-1]), c[i] + o.abs(arr[i+1] - arr[i]))
}
o.o(c[n-1])

Measured memory_bytes: 32576
n=int(input())
s=input()
sd={}
for si in s:
    if si in sd.keys():
        sd[si]+=1
    else:
        sd[si]=1
for i in range(n-1):
    st=input()
    for k in sd:
        if st.count(k)<sd[k]:
            sd[k]=st.count(k)
ans=''
for k in sd:
    ans+=k*sd[k]
print(''.join(sorted(ans)))

Measured memory_bytes: 3064
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,a;
  cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else{cout<<10<<endl;}
  
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    
    int x=-1,y=-1,z=-1;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i+j<=n){
                if(i*10000 + j*5000 + (n-i-j)*1000==m){
                    x=i;
                    y=j;
                    z=n-i-j;
                }
            }
        }
    }
    
    cout<<x<<" "<<y<<" "<<z<<endl;
    
    return 0;
}

Measured memory_bytes: 256
N=gets.to_i
S=gets.chomp.split("")
b=[0]
w=[0]
0.upto(N-1) do |i|
  if S[i] == "#"
    b << b[-1]+1
  else
    b << b[-1]
  end
end
(N-1).downto(0) do |i|
  if S[i] == "."
    w << w[-1]+1
  else
    w << w[-1]
  end
end
w.reverse!
ans = 10**6
0.upto(N) do |i|
  ans = b[i] + w[i] if b[i] + w[i] < ans
end
puts ans

Measured memory_bytes: 19964
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<string>
using namespace std ;
int n,a[200005] ;
int main(){
    scanf("%d",&n) ;
    for(int i=1;i<=n;++i) scanf("%d",&a[i]) ;
    int max=-1,max2t=-1,chk=0;
    for(int i=1;i<=n;++i){
        if(a[i]>max){
            max2t = max ; max = a[i] ; chk=0 ;
        }
        else if(a[i]==max) chk=1 ;
        else if(a[i]>max2t) max2t=a[i] ;
    }
    for(int i=1;i<=n;++i){
        if((a[i]!=max) || (chk)) cout<<max<<endl ;
        else cout<<max2t<<endl ;
    }
    return 0 ;
}

Measured memory_bytes: 2432
import math
N,H = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
a = 0
for i in range(N):
    if A[i][0]>a:
        a = A[i][0]
B = []
for i in range(N):
    if A[i][1]>a:
        B.append(A[i][1])
B = sorted(B,reverse=True)
totB = sum(B)
if totB>=H:
    flag = 0
    tot = 0
    for i in range(len(B)):
        tot += B[i]
        if tot>=H:
            flag = i+1
            break
    print(flag)
else:
    h = H-totB
    n = len(B)+math.ceil(h/a)
    print(n)

Measured memory_bytes: 96840
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = input.split("\n")[0].split("");
  let counter = 0;
  for (let i = 0; i < Math.ceil(input.length / 2); i++) {
    if (input[i] !== input[input.length - 1 - i]) counter++;
  }
  console.log(counter);
}


Measured memory_bytes: 7372
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define mod 998244353
//#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1000050;
//↑templete
int main() {
	int M,D;
	cin>>M>>D;
	int ans=0;
	for(int i=1;i<=M;i++){
		for(int j=1;j<=D;j++){
			int a=j/10,b=j%10;
			if(a>=2 && b>=2 && a*b==i)
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
ll S[2001],T[2001];
ll dp[2001][2001];
int main(){
    cin>>N>>M;
	for(ll i=1;i<=N;i++)cin>>S[i];
	for(ll i=1;i<=M;i++)cin>>T[i];
	for(ll i=1;i<=N;i++){
		for(ll j=1;j<=M;j++){
			dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
			dp[i][j]=(dp[i][j]+(dp[i-1][j]-dp[i-1][j-1]+MOD)%MOD)%MOD;
			if(S[i]==T[j]){
				dp[i][j]=(dp[i][j]+dp[i-1][j-1]+1)%MOD;
			}
		}
	}
	cout<<dp[N][M]+1<<endl;
    return 0;
}

Measured memory_bytes: 31488
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

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

    cout << 800 * N - (N / 15) * 200;
    return 0;
}

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

int main() {
	int a,b,c;
  	cin>>a>>b>>c;
  	int kind=3;
  	if(a==b || b==c) kind--;
  	if(a==c) kind--;
  	cout<<kind<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string name[52];
string code[52];
set<char> vowl;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    vowl.insert('a');
    vowl.insert('e');
    vowl.insert('u');
    vowl.insert('i');
    vowl.insert('o');
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        for(int i = 1; i <= n; i++) {
            //cerr << i << endl;
            cin >> name[i];
            code[i] = "";
            code[i].push_back(name[i][0]);
            for(int j = 1; j < name[i].size(); j++) {
                if(vowl.find(name[i][j-1]) != vowl.end()) code[i].push_back(name[i][j]);
            }
        }
        int ans = -1;
        for(int k = 50; k >= 1; k--) {
            //cerr << k << endl;
            set<string> used;
            bool clear = true;
            for(int i = 1; i <= n; i++) {
                string now = code[i].substr(0, k);
                if(used.find(now) != used.end()) clear = false;
                used.insert(now);
            }
            if(clear) ans = k;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3164
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i64,
    }
    println!("{}", n * (n - 1) / 2);
}


Measured memory_bytes: 4352
a,b,k = map(int,input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        a //= 2
        b += a
    else:
        if b % 2 == 1:
            b -= 1
        b //= 2
        a += b
print(a,b)

Measured memory_bytes: 2940
h, w = gets.chomp.split(" ").map(&:to_i)

area = []
h.times do |i|
  row = gets.chomp.split("")
  area << row
end
ans = []
h.times do |i|
  row = []
  w.times do |j|
    if area[i][j] == "#"
      row << "#" 
      next
    end
    count = 0
    (i-1..i+1).each do |a|
      (j-1..j+1).each do |b|
        if a < 0 || a >= h || b < 0 || b >= w
          next
        elsif a == i && b == j
          next
        end
        count += 1 if area[a][b] == "#"
      end
    end
    row << count
  end
  ans << row
end
h.times do |i|
  puts ans[i].join
end


Measured memory_bytes: 2172
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = sum(A)
C = Counter(A)

for i in range(Q):
  b, c = map(int, input().split())
  if C[b] != 0:
    cnt = C[b]
    C[c] += cnt
    C[b] = 0
    ans += (c-b) * cnt
  print(ans)

Measured memory_bytes: 21408
#include <bits/stdc++.h>
using namespace std;
long long n; long double jedan=1.00000000000000000;
long double p[3005], dp[3005][3005], ans;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n; for (int i=1; i<=n; i++) cin >> p[i];
dp[0][0]=jedan;
for (int i=1; i<=n; i++){
	for (int j=0; j<=i; j++){
		dp[i][j] = dp[i-1][j] * (jedan-p[i]);
		if (j) dp[i][j] += dp[i-1][j-1] * p[i];
	}
}
for (int j=(n+1)/2; j<=n; j++) ans+=dp[n][j];
cout << setprecision(15) << ans;
return 0;
}


Measured memory_bytes: 85596
//Admission Fee
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		 int n =Integer.parseInt(in.readLine());
		 
		 for(int i=0;i<n;i++){

			 String[] xybp = in.readLine().split(" ");

			 int x= Integer.parseInt(xybp[0]);
			 int y= Integer.parseInt(xybp[1]);
			 int b= Integer.parseInt(xybp[2]);
			 int p= Integer.parseInt(xybp[3]);
			 
			 int reg = x * b + y * p;
			 
			 if(b<5){
				 b=5;
			 }
			 if(p<2){
				 p=2;
			 }
			 
			 int dis = (int)(0.8 * (x * b + y * p));
			 
			 if(reg<dis){
				 System.out.println(reg);
			 }else{
				 System.out.println(dis);
			 }
			 
		 }
		 
	}
}

Measured memory_bytes: 19528
#include <cstring>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int n, a[50], x[50][50], y[50][50];
int b[50], bb[50], ans;

inline int max(int a, int b){
	return a > b ? a : b;
}

void check(){
	memset(bb, -1, sizeof(bb));
	for(int i = 1; i <= n; i++){
		if(b[i] == 1){
			for(int j = 1; j <= a[i]; j++){
				if(b[x[i][j]] != y[i][j]) return;
			}
		}
	}
	int sum = 0;
	for(int i = 1; i <= n; i++)
		sum += b[i];
	//puts(""); 
	if(ans < sum) ans = sum;
}

void dfs(int k){
	if(k == n){
		check();
		return;
	}
	for(int i = 0; i <= 1; i++){
		b[k + 1] = i;
		dfs(k + 1);
	}
}

int main(){

	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		for(int j = 1; j <= a[i]; j++)
			scanf("%d%d", &x[i][j], &y[i][j]);
	}
	dfs(0);
	printf("%d\n", ans); 

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int s1[20000] , s2[20000] , s3[20000] , top1 = 0 , top2 = 0 , top3 = 0;

void push1(int x);
void push2(int x);
void push3(int x);
int pop1();
int pop2();
int pop3();

int main(void)
{
	char ch[20000];
	int i = 0 , j = 0 , k = 0 , sum = 0;
	scanf("%s",ch);
	
	while(ch[i] == '\\' || ch[i] == '_' || ch[i] == '/')
	{
		if(ch[i] == '\\')push1(i);
		else if(ch[i] == '/' && top1 != 0)
		{
			j = pop1();
			k = i - j;
			sum += k;
			while(top2 != 0 && j < s2[top2])
			{
				pop2();
				k += pop3();
			}
			push2(j);
			push3(k);
		}
		i++;
	}
	printf("%d\n",sum);
	printf("%d",top3);
	
	for( i = 1; top3 != 0; i++)
	{
		pop3();
		printf(" %d",s3[i]);
	}
	printf("\n");
	return 0;
}

void push1(int x){top1++;s1[top1] = x;}
void push2(int x){top2++;s2[top2] = x;}
void push3(int x){top3++;s3[top3] = x;}
int pop1(){top1--;return s1[top1+1];}
int pop2(){top2--;return s2[top2+1];}
int pop3(){top3--;return s3[top3+1];}


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

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

    vector<vector<int> > c(3, vector<int>(3));

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    int x;

    x = min(c[0][0], min(c[0][1], c[0][2]));

    c[0][0] -= x;
    c[0][1] -= x;
    c[0][2] -= x;

    cerr << x << endl;

    x = min(c[1][0], min(c[1][1], c[1][2]));

    c[1][0] -= x;
    c[1][1] -= x;
    c[1][2] -= x;

    cerr << x << endl;

    x = min(c[2][0], min(c[2][1], c[2][2]));

    c[2][0] -= x;
    c[2][1] -= x;
    c[2][2] -= x;

    cerr << x << endl;

    x = min(c[0][0], min(c[1][0], c[2][0]));

    c[0][0] -= x;
    c[1][0] -= x;
    c[2][0] -= x;

    cerr << x << endl;

    x = min(c[0][1], min(c[1][1], c[2][1]));

    c[0][1] -= x;
    c[1][1] -= x;
    c[2][1] -= x;

    cerr << x << endl;

    x = min(c[0][2], min(c[1][2], c[2][2]));

    c[0][2] -= x;
    c[1][2] -= x;
    c[2][2] -= x;

    cerr << x << endl;

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(c[i][j] != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
//#define ForJ(n) for(int j=0;j<n;j++)
//#define ForK(n) for(int k=0;k<n;k++)
#define Pr(n) cout<<n<<endl;
#define INS(v,n) for(int i=0;i<n;i++){cin >>v.at(i);}//vector 代入
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

int Product_set_min(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= lb;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= la;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= la;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
int Product_set_max(int la,int ra,int lb,int rb){//A<B
    int r=0;;
    if (la<ra&&ra<lb&&lb<rb) {
        r= 0;
    }else if(la<=lb&&lb<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=ra&&ra<=rb){
        r= ra;
    }else if(lb<=la&&la<=rb&&rb<=ra){
        r= rb;
    }else if(lb<rb&&rb<la&&la<ra){
        r= 0;
    }
    return r;
}
string min (string m){
    transform(m.begin(), m.end(), m.begin(),towlower);
    return m;
}
signed  main(){
    int p,q,r;
    cin>>p>>q>>r;
    vector <int> v = {p+q,q+r,r+p};
    cout<<*min_element(v.begin(), v.end())<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    bool first = true;
    string s;
    getline(cin, s);
    int i = 0;

    for(;;){
        int j = s.find_first_of("., ", i);
        if(j == string::npos){
            cout << endl;
            return 0;
        }

        string s1 = s.substr(i, j-i);
        if(3 <= s1.size() && s1.size() <= 6){
            if(first)
                first = false;
            else
                cout << ' ';
            cout << s1;
        }
        i = j+1;
    }
}

Measured memory_bytes: 0
N,K=map(int,input().split())
S=input()
if N==1:
    print(1)
    exit()


lst=[]
if S[0]!="1":
    lst.append([0,0])
flag=0
for i in range(N):
    if flag==0 and S[i]=="1":
        flag=1
        st=i
    elif flag and S[i]=="0":
        lst.append([st,i-1])
        flag=0
if S[-1]!="1":
    lst.append([N-1,N-1])

if flag:
    lst.append([st,N-1])

if K>=len(lst):
    print(N)
    exit()
else:
    value=0
    for i in range(len(lst)-K):
        a=lst[i+K][1]-lst[i][0] +1
        if a>value:
            value=a
print(value)


Measured memory_bytes: 46192
N, M = map(int, input().split())
P = [int(x) for x in input().split()]

XY = [0]*M
for i in range(M):
    X, Y = [int(x) for x in input().split()]
    XY[i] = X, Y

# x != y

parent = [x for x in range(N+1)]

def union(x, y):
    px = find(x)
    py = find(y)
    if px != py:
        parent[py] = px
    # if px != py:
    #    parent[x] = px
    #    parent[y] = px

def find(x):
    if parent[x] == x:
        return x
    parent[x] = find(parent[x])
    return parent[x]
        
for x, y in XY:
    union(x, y)

cnt = 0
if False:
    print("P     ", " ".join(str(x) for x in P))
    print("parent", " ".join(str(x) for x in parent[1:]))
    print("same  ", " ".join("*" if find(i+1) == find(p) else " " for i, p in enumerate(P)))
for i, p in enumerate(P):
    if find(i+1) == find(p):
        cnt += 1
print(cnt)




Measured memory_bytes: 25000
/*
    abcde->CBAde->CBEDa->ebcDa->ebAdC->aBcDe
    ->adCbe->cDAbe->cBade->AbCde
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int n, a[N][3], p[N], t[2];
bool Check() {
    for (int i = 1; i <= n; i++) {
        p[i] = a[i][1] / 3 + 1;
        if (!(a[i][1] - a[i][0] == 1 && a[i][2] - a[i][1] == 1 &&
                  a[i][0] % 3 == 1 ||
              a[i][0] - a[i][1] == 1 && a[i][1] - a[i][2] == 1 &&
                  a[i][2] % 3 == 1))
            return 0;
        if (abs(i-p[i])&1) return 0; 
        t[i & 1] ^= (a[i][0] > a[i][2]);
    }
    for (int i = 1; i <= n; i++) {
        while (p[i] != i) {
            t[i & 1 ^ 1] ^= 1;
            swap(p[i], p[p[i]]);
        }
    }
    return !t[0] && !t[1];
}
int main() {
    scanf("%d", &n);
    for (int k = 0; k < 3; k++) {
        for (int i = 1; i <= n; i++) {
            scanf("%d", &a[i][k]);
        }
    }
    if (Check())
        puts("Yes");
    else
        puts("No");
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int mod = 1e9 + 7;
const int mN = 1e9;

int n, w;

main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n>>w;
  vector<pair<ll, ll>> arr(n);
  for(int i = 0, x, y; i < n; ++i){
    cin>>x>>y;
    arr[i] = make_pair(x, y);
  }
  vector<vector<ll>> dp(n + 1, vector<ll> (w + 1));

  for(int i = 0; i <= n; ++i){
    for(int j = 0; j <= w; ++j){
      if(i == 0 || j == 0) dp[i][j] = 0;
      else if(arr[i - 1].first <= j) dp[i][j] = max(arr[i - 1].second + dp[i - 1][j - arr[i - 1].first], dp[i - 1][j]);
      else dp[i][j] = dp[i - 1][j];
    }
  }
  cout<<dp[n][w]<<"\n";
}


Measured memory_bytes: 82964
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N, C, K =I()
T = []
for i in range(N):
    t = k()
    T.append(t)

T.sort()
a = T[0]+K
pas = 0
ans = 1

for i in range(N):
    if pas == C or a < T[i]:
        pas = 1
        ans += 1
        a = T[i]+K
    else:
        pas += 1

print(ans)


Measured memory_bytes: 14128
N, S = int(input()), input()
stk = []
for s in S:
    if len(stk) == 0 or stk[-1] == ')' or s == '(':
        stk.append(s)
    else:
        stk.pop()

print('(' * stk.count(')') + S + ')' * stk.count('('))


Measured memory_bytes: 2940
n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
c = [int(x) for x in input().split(' ')]

cnt = 0
ss = -10

for i in a :
    i -= 1
    cnt += b[i]
    if (i - ss == 1) :
        cnt += c[ss]
        
    ss = i



print(cnt)

Measured memory_bytes: 3064
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    a = inpl()
    ans = 0
    cnt = 0
    dic = defaultdict(int)
    dic[cnt] += 1
    for i in range(n):
        cnt += a[i]
        cnt %= m
        dic[cnt] += 1
    for e in dic:
        ans += dic[e]*(dic[e]-1)//2
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 16576
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int N, A;//Nは合計金額、Aは1円の枚数
	int rest;

	cin >> N >> A;

	rest = N % 500;

	if((rest==0)||(rest<=A)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string s;
  long K;
  cin >> s >> K;

  set<string> st;
  for (long i = 0; i < s.size(); i++) {
    for (long j = 1; i+j <= s.size() && j <= 5; j++) {
      st.insert(s.substr(i, j));
    }
  }

  auto it = st.begin();
  rep (i, K-1) it++;
  
  cout << *it << endl;
}

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


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	ll N;
	cin >> N;
	vector<ll> x;
	ll ans = 0;
	rep(i, N) {
		ll a;
		cin >> a;
		if (i == 0) {
			x.push_back(-a);
			ans = 1;
			continue;
		}
		if (-x[ans - 1] >= a) {
			x.push_back(-a);
			ans++;
			continue;
		}
		*upper_bound(x.begin(), x.end(), -a) = -a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int main(){
	//	freopen("in.txt","r",stdin);
	ll N;
	ll X[100100];
	ll ans=0;
	ll A,B;//単位疲労度A、ワープ疲労度B
	cin >> N >> A >> B;
	for (int i = 0; i < N; ++i)
	{
		scanf("%lld",&X[i]);
	}
	for (int i = 1; i < N; ++i)
		{
			ans += min((X[i]-X[i-1])*A,B);
		}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

class teamInfo{
public:
	int id;
	int u;
	int a;
	int p;

	bool operator<(const teamInfo &ti)const{
		if(ti.a < this->a)
			return true;
		else if(ti.a > this->a)
			return false;
		else{
			if(ti.p < this->p)
				return false;
			else if(ti.p > this->p)
				return true;
			else{
				if(ti.id > this->id)
					return true;
				else
					return false;
			}
		}
	}
};

int main(){

	int n;
	while(cin >> n && n !=0){
		vector<teamInfo> v;
		map<int,int> ucnt;

		for(int i = 0; i < n; i++){
			teamInfo ti;
			cin>>ti.id>>ti.u>>ti.a>>ti.p;
			v.push_back(ti);
		}
		sort(v.begin(),v.end());

		int team=0;
		for(int i = 0; i < n; i++){
			if(team < 10){
				ucnt[v[i].u]++;
				if(ucnt[v[i].u] >= 4){
					ucnt[v[i].u]--;
				}
				else{
					cout << v[i].id << endl;
					team++;
				}
			}
			else if(team < 20){
				ucnt[v[i].u]++;
				if(ucnt[v[i].u] >= 3){
					ucnt[v[i].u]--;
				}
				else{
					cout << v[i].id << endl;
					team++;
				}
			}
			else if(team < 26){
				ucnt[v[i].u]++;
				if(ucnt[v[i].u] >= 2){
					ucnt[v[i].u]--;
				}
				else{
					team++;
					cout << v[i].id << endl;
				}
			}
		}
	}

	return 0;
}

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


int main(){
	int a, b, c;
	cin >> a >> b >> c;

	cout << ((a <= c && c <= b) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256