akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=lst[a];i;i=nxt[i])
using namespace std;

typedef long long ll;

const int N=55,M=N*N*N;
const ll inf=1e13;

int t[N],nxt[N],lst[N],l;
void add(int x,int y) {t[++l]=y;nxt[l]=lst[x];lst[x]=l;}

int n,m,T,d,x,sz[N],q[M],ord[N];
ll w[N],f[M],g[M];

void dfs(int x) {
	sz[x]=1;
	rep(i,x) dfs(t[i]),w[x]+=w[t[i]],sz[x]+=sz[t[i]];
}

bool cmp(int x,int y) {return sz[x]*w[y]>sz[y]*w[x];}

int main() {
	scanf("%d%d%d",&n,&T,&d);
	fo(i,1,n) {
		scanf("%d",&w[i]);
		if (i>1) {
			scanf("%d",&x);
			add(x,i);
		}
	}
	dfs(1);
	fo(i,1,n) m+=sz[i]*(i==1?n:min(n,d));
	fo(i,1,m) f[i]=inf;
	fo(i,1,n) {
		if (i==1) fo(j,sz[i],m) f[j]=min(f[j],f[j-sz[i]]+w[i]);
		else {
			fo(r,0,sz[i]-1) {
				int hd=1,tl=0;
				for(int j=r;j<=m;j+=sz[i]) {
					while (hd<=tl&&f[j]-f[q[tl]]<=(j-q[tl])/sz[i]*w[i]) tl--;
					q[++tl]=j;
					if ((j-q[hd])/sz[i]>min(n,d)) hd++;
					g[j]=f[q[hd]]+(j-q[hd])/sz[i]*w[i];
				}
			}
			fo(j,0,m) f[j]=g[j];
		}
	}
	fo(i,1,n) ord[i]=i;
	sort(ord+1,ord+n+1,cmp);
	int ans=0;
	fo(i,0,m)
		if (f[i]<=T) {
			int ret=T-f[i],now=i;
			fo(j,1,n) {
				int x=ord[j];ll k=min((ll)(x==1?1e9:d-min(n,d)),ret/w[x]);
				ret-=k*w[x];now+=k*sz[x];
			}
			ans=max(ans,now);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
hp,n=map(int,input().split())

skills=[tuple(map(int,input().split())) for _ in range(n)]

dp=[10**30]*(10**4+1)

dp[hp]=0

for a,b in skills:
    for h in range(hp,0,-1):
        if h-a>=0:
            dp[h-a]=min(dp[h-a],dp[h]+b)
        else:
            dp[0]=min(dp[0],dp[h]+b)
            
print(dp[0])

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

int main() {
  int n;
  scanf("%d", &n);
  int m;
  std::vector<int> v;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &m);
    v.push_back(m);
  }

  std::sort(v.begin(), v.end(), std::greater<int>());
  int total = 0;
  for (int a : v) {
    if (total == 0) {
      total += (a / 2);
    } else {
      total += a;
    }
  }
  printf("%d\n", total);

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int>r(n);
    rep(i,n) cin >> r[i];
    
    int ans = -2000000000;
    int Min = r[0];
    for(int i=1; i<n; ++i) {
        ans = max(ans, r[i]-Min);
        Min = min(Min, r[i]);
    }
    cout << ans << endl;
    return 0;
}



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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
using i64 = int_fast64_t;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);

    int n; cin >> n;
    string s; cin >> s;
    rep(i,s.size()) {
        char ch = s[i];
        char ans = ch + n;
        if(ans>'Z') ans -= 26;
        cout << ans;
    }
    cout << '\n';
}

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

int main()
{
    string u;

    cin>>u;

    for(int i = 0; i<u.size(); i++) {
        if(u[i]!=','){
            cout<<u[i];
        }
        else
            cout<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,cnt=0;
	cin>>n>>m;
	int m_atc=m;
	while(m_atc)
	{
		
		m_atc/=10;
		cnt++;
	}
	n=n*pow(10,cnt)+m;
	if(sqrt(n)==floor(sqrt(n)))cout<<"Yes";
	else cout<<"No";
	
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;

int A, B, C;
int X, Y;

int main() {
    scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
    C <<= 1;
    int ans = 0;
    if (A+B > C) {
        int t = min(X, Y);
        ans += t*C;
        X -= t; Y -= t;
    }
    if (C < A) {ans += X*C, Y -= X;} else ans += A*X;
    if (C < B) ans += Y*C; else ans += B*Y;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: isize
    }

    for a in 1..=3500 {
        for b in 1..=3500 {
            let numer = n * a * b;
            let denom = 4 * a * b - n * a - n * b;
            if denom == 0 || numer % denom != 0 {
                continue;
            }
            let c = numer / denom;
            if c <= 0 || c > 3500 {
                continue;
            }
            println!("{} {} {}", a, b, c);
            return;
        }
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  int sum = 0;
  for(int i = 0; i<=n; i++) {
    sum+=i;
  }
  cout << sum << endl;

  return 0;
}




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

int Dice[6];

void shake(char c){
  if(c == 'E'){
    swap(Dice[0], Dice[3]);
    swap(Dice[3], Dice[5]);
    swap(Dice[5], Dice[2]);
  }
  if(c == 'N'){
    swap(Dice[0], Dice[1]);
    swap(Dice[1], Dice[5]);
    swap(Dice[5], Dice[4]);
  }
  if(c == 'S'){
    swap(Dice[1], Dice[0]);
    swap(Dice[0], Dice[4]);
    swap(Dice[4], Dice[5]);
  }
  if(c == 'W'){
    swap(Dice[3], Dice[0]);
    swap(Dice[0], Dice[2]);
    swap(Dice[2], Dice[5]);
  }
}

int main(){
  int i;
  char c;
  for(i = 0; i < 6; i++){
    cin >> Dice[i];
  }
  while(cin >> c) shake(c);

  cout << Dice[0] << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct Pair {
    int num;
    int pos;
    int sortedPos;
};

bool comparePairs(Pair *a, Pair *b)
{
    return a->num < b->num;
}

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

    Pair numbers[n];
    for(int i=0;i<n;i++){
        int temp;
        scanf("%d", &temp);
        numbers[i].num = temp;
        numbers[i].pos = i;
    }

    // Shallow copy
    Pair* sortedCopy[n];
    for (int i=0; i <n; i++) {
        sortedCopy[i] = &(numbers[i]);
    }
    // Sort
    sort(sortedCopy, sortedCopy + n, comparePairs);

    // Assign index
    int i = 0;
    for (Pair *p : sortedCopy) {
        p->sortedPos = i++;
    }

    // Get medians
    int medianIndex = (n - 1) / 2;
    int median = sortedCopy[medianIndex]->num;
    int medianNext = sortedCopy[medianIndex + 1]->num;

    // Print result
    for (const Pair &p: numbers) {
        printf("%d\n", (p.sortedPos <= medianIndex) ? medianNext : median);
    }
    return 0;
}

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

int main (){
  int N,D,X,A;
  int ans = 0;

  std::cin >> N>>D>>X;

  for (int i = 0 ; i < N ; i ++ ) {
    int day = 1;

    cin >> A;
    while  (day <= D){
      day = day + A;
      ans++;

    }
  }



  std::cout << ans+X<<endl;

return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll res=-LINF;
	chmax(res,a*c);
	chmax(res,a*d);
	chmax(res,b*c);
	chmax(res,b*d);
	if(a<=0 and 0<=b) chmax(res,0ll);
	if(c<=0 and 0<=d) chmax(res,0ll);
	cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
    int n;
    string a,b,c;
    cin>>n>>a>>b>>c;
    int ans = 0;
    for(int i=0;i<n;i++){
        set<char>s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        if(s.size()==3)ans+=2;
        if(s.size()==2)ans+=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){
  int i,j,n,l[300],u[300],a[300],p[300],team[1000],top,aa,senbatu[300],c;
  while(1){
    c = 0;
    scanf("%d",&n);
    if(n == 0) break;
    for(i=0;i<n;i++){
      scanf("%d%d%d%d",&l[i],&u[i],&a[i],&p[i]);
      senbatu[i] = 0;
    }
    for(i=0;i<1000;i++) team[i] = 0;

    for(i=0;i<n;i++){
      top = i;
      for(j=i;j<n;j++){
	if(a[j] > a[top]) top = j;
	else if(a[j] == a[top] && p[j] < p[top]) top = j;
	else if(a[j] == a[top] && p[j] == p[top] && l[j] < l[top]) top = j;
      }
      aa = l[i];
      l[i] = l[top];
      l[top] = aa;
      aa = u[i];
      u[i] = u[top];
      u[top] = aa;
      aa = a[i];
      a[i] = a[top];
      a[top] = aa;
      aa = p[i];
      p[i] = p[top];
      p[top] = aa;
    }

    for(i=0;i<n;i++){
      if(c < 10 && team[u[i]] < 3){
	senbatu[i] = 1;
	team[u[i]]++;
	c++;
      }
      else if(c >= 10 && c < 20 && team[u[i]] < 2){
	senbatu[i] = 1;
	team[u[i]]++;
	c++;
      }
      else if(c >= 20 && c < 26 && team[u[i]] == 0){
	senbatu[i] = 1;
	team[u[i]]++;
	c++;
      }
    }

    for(i=0;i<n;i++){
      if(senbatu[i] == 1) printf("%d\n",l[i]);
    }
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int v[n];
  int c[n];
  for (int i=0;i<n;i++){
    cin >> v[i];
  }
  for (int i=0;i<n;i++){
    cin >> c[i];
  }
  int ans=0;
  for (int i=0;i<n;i++){
    ans+=v[i]>c[i]?v[i]-c[i]:0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main() {
	//cin.tie(0)->sync_with_stdio(0);
    int a = 1000;
    int n;
    cin >> n;
    while(a < n) a += 1000;

    cout << a-n << "\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int h, w;
    cin >> h >> w;
    int cnt = 0;
    rep(i, h)
    {
        string s;
        cin >> s;
        rep(i, w) if (s[i] == '#') cnt++;
    }
    cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
def abc179b():
    n = int(input())
    cnt = 0
    flg = False
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = True
    if flg:
        print('Yes')
    else:
        print('No')
abc179b()

Measured memory_bytes: 62348
my $n=<>; chomp $n;
my $numbers=<>;chomp$numbers;
my @a=split(/ /,$numbers);
my @sorted=sort{ $a <=> $b } @a;
my@t;my $sorted;my $t;
if($n%2==0){foreach(1..$n/2) {push(@t,$_*2-1,$_*2-1);}$n=$n/2;}
		else{push(@t,0);foreach(1..($n-1)/2){push(@t,$_*2,$_*2);}$n=($n-1)/2;}

$sorted=join('/',@sorted);$t=join('/',@t);
my $answer=0;my $counter=0;
if($sorted eq $t){$answer++; while($counter<$n){$answer=$answer*2%(10**9+7);$counter++;}}
print $answer;

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

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

  int val = 1;
  for (int i = 0; i < n; i++) {
    int a = val * 2;
    int b = val + k;

    val = min(a, b);
  }

  cout << val << endl;
}

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

  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define in insert
  #define ld long double


  #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(...) 1
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

  typedef long long int ll;

  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef vector<pii> vpii;
  typedef vector<pll> vpll;
  const ll mod =1e9+7;
  const ll MAX_NODES =200001;
  const ll MAX_LOG =50;
  const ll maxn = 400000+10;
  #define endl '\n'
  // ll power(ll x, ll n) {
  //     ll res = 1;
  //     for (; n > 0; n >>= 1) {
  //     if (n & 1) res = (res * x) % mod;
  //     x = (x * x) % mod;
  //     }
  //     return res;
  // }
const ll md = (ll) 1e9 + 7;
 
inline ll add(ll a, ll b) {
  a += b;
  if (a >= md) a -= md;
  return a;
}
 
inline ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += md;
  return a;
}
 
inline ll mul(ll a, ll b) {
  return (ll) ((long long) a * b % md);
}
 
inline ll power(ll a, long long b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline ll inv(ll a) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  ll f[maxn];
  void init()
  { 
    f[0] = 1;
    for(ll i=1;i<maxn;i++)
    {
      f[i] = mul(f[i-1],i);
    }
  }
  ll nck(ll n,ll k)
  {
    ll temp = mul(f[n],mul(power(f[k],mod-2),power(f[n-k],mod-2)));
    return temp;
  }

  int main()
  {

  IOS
  ll n,k;
  cin>>n>>k;
  init();
  if(k>=n-1)
  {
    ll ans = nck(2*n-1,n-1);
    cout<<ans<<endl;
    return 0;
  }
  ll sign = -1;
  ll ans= 0;
  for(ll i=0;(i)<=k;i++)
  {
    // ll rem = (n-(k+2)*i);
    // trace(rem);
    // if(i%2==0)
    //   ans = add(ans,mul(nck(n,i),nck(n+rem-1,rem)));
    // else
    // {
    //   ans = sub(ans,mul(nck(n,i),nck(n+rem-1,rem)));
    // }
    // trace(ans);
    ans = add(ans,mul(nck(n-1,n-i-1),nck(n,i)));
  }
  cout<<ans<<endl;
  
  


  
  

}


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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n;
int a[maxn];
int main()
{
	cin>>n;
	int num=1,cnt=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==num)
			++num,++cnt;
	}
	if(!cnt)
		cout<<-1<<endl;
	else
		cout<<n-cnt<<endl; 
	return 0;
}

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

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

    int x = a.size();
    int y = b.size();
    if (x > y) {
        cout << "GREATER" << endl;
    }
    else if (x < y) {
        cout << "LESS" << endl;
    }
    else { // x == y
        if (a > b) {
            cout << "GREATER" << endl;
        }
        else if (a < b) {
            cout << "LESS" << endl;
        } else {
            cout << "EQUAL" << endl;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp111 {
    class Program {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');

            int H = int.Parse(input1[0]);
            int W = int.Parse(input1[1]);
            int sum1 = H * W;

            int h = int.Parse(input2[0]);
            int w = int.Parse(input2[1]);

            int HW = W * h;
            int zan = (H - h) * w;
            int sum2 = HW + zan;

            int ans = sum1 - sum2;

            Console.WriteLine(ans);
            
        }
    }
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,ans;
    string s;

    cin>>n>>s;
    ans=n;
    vector<int> wh(n+1);
    forn(i,0,n)
    	wh[i+1]=wh[i]+(s[i]=='W');
    forn(i,0,n+1)
    	ans=min(ans,wh[i]+n-i-(wh[n]-wh[i])-min(wh[i],n-i-(wh[n]-wh[i]))), debug(ans);
    cout<<ans<<'\n';
    
    return 0;
}

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

using namespace std;

typedef long long ll;

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

    for(int i = 1; i< 1e4; ++i)
    {
        if(i*8/100 == a && i *10/100 == b)
        {
            cout << i;
            return 0;
        }
    }
    cout <<  -1;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
SumA = [0]
for i in range(N):
    SumA.append(SumA[-1] + A[i])

def DS(i, a, b, L = list):
    lower, higher = a, b
    while higher - lower > 1:
        mid = (lower + higher)//2
        if L[mid] > i: higher = mid
        else: lower = mid
    return lower

Ans = 1
for i in reversed(range(N-1)):
    lim = DS(A[i]*2, i, N, A)
    if lim == N-1: Ans += 1
    elif 2 * (SumA[lim+1] - SumA[0]) >= A[lim+1]: Ans += 1
    else: break

print(Ans)

Measured memory_bytes: 14480
import collections
gcd = lambda x, y: gcd(y, x % y) if x % y else y
A, B = [int(_) for _ in input().split()]


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


print(1 + len(collections.Counter(prime_factorize(gcd(A, B)))))


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

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

  if (s == "SUN") {
    cout << 7 << endl;
  } else if (s == "MON") {
    cout << 6 << endl;
  } else if (s == "TUE") {
    cout << 5 << endl;
  } else if (s == "WED") {
    cout << 4 << endl;
  } else if (s == "THU") {
    cout << 3 << endl;
  } else if (s == "FRI") {
    cout << 2 << endl;
  } else if (s == "SAT") {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n%1000==0){
			System.out.println(0);
		}
		else {
			System.out.println(1000-(n%1000));
		}
		
		
	}
}


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
	int N,K;
	int ans = 0;
	cin >> N >> K;
	vector<int> d(K);
	vector<int> A(N);
	vector<int> B(N);
	rep(i, N)B[i] = 0;
	rep(i, K) {
		cin >> d[i];
		rep(j, d[i]) {
			cin >> A[j];
			B[A[j]-1]++;
		}
	}
	rep(i,N){
		if (B[i] == 0)ans++;
		
	}
	cout << ans;

	
}

Measured memory_bytes: 3652
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;

void chain(char map[8][8], int baseX, int baseY){
	int vec[7] = { 3, 2, 1, 0, -1, -2, -3 };

	map[baseY][baseX] = '2';
	for (int i = 0; i < 7; i++){

		// for DEBUG
		/*for (int j = 0; j < 8; j++){
			for (int k = 0; k < 8; k++){
				cout << map[j][k];
			}
			cout << endl;
		}
		cout << "-------------- i = " << i << " END" << endl;*/


		// 同列爆風
		// 行が0~7かどうか
		if (baseY + vec[i] >= 0 && baseY + vec[i] <= 7){

			// for DEBUG
			// cout << "nowCheck (" << baseX+1 << ", " << baseY + vec[i]+1 << ")" << endl;

			if (map[baseY + vec[i]][baseX] == '1'){
				chain(map, baseX, baseY + vec[i]);
			}
			else{
				map[baseY + vec[i]][baseX] = '2';
			}
		}
		// 同行爆風
		// 列が0~7かどうか
		if (baseX + vec[i] >= 0 && baseX + vec[i] <= 7){

			// for DEBUG
			// cout << "nowCheck (" << baseX + vec[i] + 1 << ", " << baseY+ 1 << ")" << endl;

			if (map[baseY][baseX + vec[i]] == '1'){
				chain(map, baseX + vec[i], baseY);
			}
			else{
				map[baseY][baseX + vec[i]] = '2';
			}
		}
	}
}

void solve(char map[8][8], int x, int y){
	int vec[7] = { 3, 2, 1, 0, -1, -2, -3 };

	chain(map, x, y);
	for (int i = 0; i < 8; i++){
		for (int j = 0; j < 8; j++){
			if (map[i][j] != '1'){
				map[i][j] = '0';
			}
		}
	}
}

int main(){
	char map[8][8] = {};
	int mapnum = 0, x = 0, y = 0;
	cin >> mapnum;
	for (int i = 0; i < mapnum; i++){
		for (int j = 0; j < 8; j++){
			for (int k = 0; k < 8; k++){
				cin >> map[j][k];
			}
		}
		cin >> x;
		cin >> y;
		solve(map, --x, --y);

		cout << "Data " << (i + 1) << ":" << endl;
		for (int j = 0; j < 8; j++){
			for (int k = 0; k < 8; k++){
				cout << map[j][k];
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
//Sum and Average
#include<bits/stdc++.h>
using namespace std;

int main(){
  int p, n, sp=0, sn=0, a=0;
  while(scanf("%d,%d", &p, &n)!=EOF){
    if(p==0)break;
    sp+=(p*n);
    sn+=n;
    a++;
  }
  printf("%d\n%d\n", sp, (int)round((double)sn/(double)a));
  return 0;
}

Measured memory_bytes: 1196
import java.io.*;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int K = sc.nextInt();
    String S = sc.next();
    char[] letters = S.toCharArray();

    String ans = "";
    if (S.length() > K){
      ans = S.substring(0, K);
      ans += "...";
    }else {
      ans = S;
    }
    out.println(ans);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 36860
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int x;
   cin>>x;

   for(long int i = -1e3; i <= 1e3; i++)
   	for(long int j = -1e3; j <= 1e3; j++){
   		long int val = i*i*i*i*i - j*j*j*j*j;
   		if(val == x)
   			return cout<<i<<" "<<j,0;
   	}

   	cout<<"-1";
   return 0;
}

Measured memory_bytes: 3604
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<list>
#include<sstream>
using namespace std;
int main()
{
	int r;
	cin>>r;
	if(0<=r&&r<=4208&&r<1200)
	cout<<"ABC";
	if(0<=r&&r<=4208&&1200<=r&&r<2800)
	cout<<"ARC";
	if(0<=r&&r<=4208&&2800<=r)
	cout<<"AGC";
	return 0;
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

H, W = l_inpl()
field = [ input() for _ in range(H) ]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for hi in range(H):
    for wi in range(W):
        now = field[hi][wi]
        if now == "#":
            L[hi][wi] = 0
        else:
            if wi == 0:
                L[hi][wi] = 1
            else:
                L[hi][wi] = L[hi][wi-1] + 1

for hi in range(H):
    for wi in range(W)[::-1]:
        now = field[hi][wi]
        if now == "#":
            R[hi][wi] = 0
        else:
            if wi == W-1:
                R[hi][wi] = 1
            else:
                R[hi][wi] = R[hi][wi+1] + 1

for hi in range(H):
    for wi in range(W):
        now = field[hi][wi]
        if now == "#":
            U[hi][wi] = 0
        else:
            if hi == 0:
                U[hi][wi] = 1
            else:
                U[hi][wi] = U[hi-1][wi] + 1

for hi in range(H)[::-1]:
    for wi in range(W):
        now = field[hi][wi]
        if now == "#":
            D[hi][wi] = 0
        else:
            if hi == H-1:
                D[hi][wi] = 1
            else:
                D[hi][wi] = D[hi+1][wi] + 1

print(max([ L[hi][wi] + R[hi][wi] + D[hi][wi] + U[hi][wi] - 3 for hi in range(H) for wi in range(W)]))


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

int main(){
    int a;
    cin >> a;
    int b=a;
    vector<int> data(a);
    for(int i=0; i<data.size(); i++){
        data.at(i) = b;
        b--;
    }

    double count = 0;
    for(int i=0; i<data.size(); i++){
        if(data.at(i) % 2 != 0) count++;
    }

    double ans = count / a;
    cout << fixed << setprecision(15);

    cout << ans << endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <cxxabi.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()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

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

    int ans = 0;
    rep(i, N-2)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            ans++;
        }
    }

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


Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-01
**/

#include <bits/stdc++.h>
using namespace std;

const long long INF = 1e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<long long> pref(n), suff(n);
    pref[0] = a[0];
    for (int i = 1; i < n; i++) {
        pref[i] = pref[i-1] + a[i];
    }
    suff[n-1] = a[n-1];
    for (int i = n-2; i >= 0; i--) {
        suff[i] = suff[i+1] + a[i];
    }
    
    long long ans = INF;
    for (int i = 0; i < n-1; i++) {
        ans = min(ans, abs(pref[i] - suff[i+1]));
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7172
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    string s;
    int ans = 1;
    cin >> n;
    cin >> s;
    for(int i=1;i<n;i++){
        if(s[i] != s[i-1]){
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ul unsigned int
using namespace std;

int main()
{
    ul l,r;
     ul n=2019;
    cin>>l>>r;
    if((l-1)/2019!=(r+1)/2019)
        {
          cout<<"0";
          return 0;
        }
        ul minn=2018;
        for(ul i=l;i<=r;i++)
        {
          for(ul j=i+1;j<=r;j++)
          {
            ul t=((i%n)*(j%n))%n;
            if(t<minn)
            minn=t;
          }
        }
        cout<<minn;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int mp[21][21];
  int w,h;
  int x[4]={1,-1,0,0};
  int y[4]={0,0,1,-1};
  int m;
  bool b;
  char s;
  int ans;
  while(1){
    cin>>w>>h;
    if(w==0 && h==0) break;
    ans=0;
    for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
	mp[i][j]=0;
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>s;
	if(s=='#') mp[i][j]=1;
	else if(s=='@') mp[i][j]=2;
      }
    }
    b=true;
    while(b){
      b=false;
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  if(mp[i][j]==2){
	    /*for(int k=0;k<4;k++){*/
	      if(mp[i+1][j]==0){
		mp[i+1][j]=2;
		b=true;
	      }
	      if(mp[i-1][j]==0){
		mp[i-1][j]=2;
		b=true;
	      }
	      if(mp[i][j+1]==0){
		mp[i][j+1]=2;
		b=true;
	      }
	      if(mp[i][j-1]==0){
		mp[i][j-1]=2;
		b=true;
	      }
	  }
	}
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	/*cout<<mp[i][j]<<" ";*/
	if(mp[i][j]==2) ans++;
      }
      /* cout<<endl;*/
    }
    cout<<ans<<endl;
  }
  return 0;
}
  
    



Measured memory_bytes: 2988
n,g[11][11];
int dijkstra(start, goal){
	int c[11], f[11]={0}, i, nearest, t;
	memset(c, 1, sizeof(c));
	c[start] = 0;
	nearest=start;
	while(nearest){
		f[nearest]=1;
		for(i=1;i<=n;i++){
			t=c[nearest]+g[nearest][i];
			if(t<c[i])
				c[i]=t;
		}
		nearest=0;
		for(i=1;i<=n;i++){
			if(!f[i] && (!nearest || c[i]<c[nearest]))
				nearest=i;
		}
	}
	return c[goal];
}
int main(){
	int m,a,b,c,live,best,best_c;
	for(;scanf("%d",&m),m;){
		memset(g,1,sizeof(g));
		n=0;
		for(;m--;){
			scanf("%d%d%d",&a,&b,&c);
			a++,b++;
			g[a][b]=g[b][a]=c;
			if(a>n)n=a;
			if(b>n)n=b;
		}
		best_c=1e9;
		for(live=1;live<=n;live++){
			c=0;
			for(m=1;m<=n;m++){
				c+=dijkstra(live,m);
			}
			if(c<best_c){
				best_c=c;
				best=live;
			}
		}
		printf("%d %d\n",best-1,best_c);
	}
	exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define int unsigned long long 
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 5005
#define base 13131
#define hash jooksnef
int n;
char s[N];
int hash[N];
int mul[N];
int h(int l,int r)
{
	return hash[r]-hash[l-1]*mul[r-l+1];
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	n=read();
	scanf("%s",s+1);
	mul[0]=1;
	for(int i=1;i<=n;i++) mul[i]=mul[i-1]*base;
	for(int i=1;i<=n;i++) hash[i]=hash[i-1]*base+s[i];
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(i+ans<=j)
			{
				while(i+ans+1<=j&&j+ans<=n&&h(i,i+ans)==h(j,j+ans)) ans++;
			}
		}
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[111111];
vector<int> ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h,j;
  string s;
  cin >>a>>b;
  b=b-a;
  cout <<a+b*2<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int flag = 0;
    int matrix[3][3], n;
    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin >> matrix[i][j];

    cin >> n;
    vector<int> B(n);
    for(int i = 0; i < n; i++)
        cin >> B[i];
    int c = 0;
    while(c < n){
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(matrix[i][j] ==  B[c]){
                    matrix[i][j] = 0;
                    break;
                }
            }
        }
        c++;
    }
    
    if(matrix[0][0] == matrix[0][1] && matrix[0][0] == matrix[0][2]) flag = 1;
    else if(matrix[1][0] == matrix[1][1] && matrix[1][0] == matrix[1][2]) flag = 1;
    else if(matrix[2][0] == matrix[2][1] && matrix[2][0] == matrix[2][2]) flag = 1;
    
    else if(matrix[0][0] == matrix[1][0] && matrix[0][0] == matrix[2][0]) flag = 1;
    else if(matrix[0][1] == matrix[1][1] && matrix[0][1] == matrix[2][1]) flag = 1;
    else if(matrix[0][2] == matrix[1][2] && matrix[0][2] == matrix[2][2]) flag = 1;

    else if(matrix[0][0] == matrix[1][1] && matrix[0][0] == matrix[2][2]) flag = 1;
    else if(matrix[0][2] == matrix[1][1] && matrix[0][2] == matrix[2][0]) flag = 1;

    if(flag == 1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;    
    return 0;
}


Measured memory_bytes: 3604
n,a,b=map(int,input().split())
d=a+b
s=input()
for i in s:
  if i=="c":
    print("No")
  elif i=="a":
    if d>0:
      print("Yes")
      d-=1
    else:
      print("No")
  else:
    if d>0 and b>0:
      print("Yes")
      d-=1
      b-=1
    else:
      print("No")

   

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];

    sort(all(a));

    int count = 0;

    ll i=0;
        if(i<n&&a[i]<400){count++;while(i<n&&a[i]<400)i++;}
        if(i<n&&a[i]<800){count++;while(i<n&&a[i]<800)i++;}
        if(i<n&&a[i]<1200){count++;while(i<n&&a[i]<1200)i++;}
        if(i<n&&a[i]<1600){count++;while(i<n&&a[i]<1600)i++;}
        if(i<n&&a[i]<2000){count++;while(i<n&&a[i]<2000)i++;}
        if(i<n&&a[i]<2400){count++;while(i<n&&a[i]<2400)i++;}
        if(i<n&&a[i]<2800){count++;while(i<n&&a[i]<2800)i++;}
        if(i<n&&a[i]<3200){count++;while(i<n&&a[i]<3200)i++;}
    ll min = count;
    if(count!=0)cout<<min<<endl;
    else cout<<1<<endl;
    cout<<min+n-i<<endl;

    return 0;
}

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

stack<char>a;
char c [100004];
int bo;

char zh ( char p );

int main()
{
	string c;
	getline(cin,c);
	for(int i=0;c[i]!='\0';i++)
	{
		a.push(c[i]);
	}
	for(int i=0;c[i]!='\0';i++)
	{
		if(c[i]==zh(a.top()))
			a.pop();
		else
		{
			bo=1;
			break;
		}
	}
	if(bo==1)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
	}
char zh(char p)
{
	switch(p)
	{
		case 'p':return 'q';
		case 'q':return 'p';
		case 'b':return 'd';
		case 'd':return 'b';
	}
	return '0';
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000007;
//------------------------------------------//
ll f(ll x){
    ll cnt=0;
    while(x%2==0){
        cnt++;
        x/=2;
    }
    return cnt;
}
int main(){
    ll N;cin>>N;
    ll ans=0;
    vector<ll> a(N);
    rep(i,N){
        cin>>a[i];
        ans+=f(a[i]);
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int N;
    int X;
    int kaisuu; 
    cin >> N >> X ;
    int kyori = 0;
    vector<int> L(N);
    for (int i = 0; i < N ; i++) {
        std::cin >> L.at(i);
    }
    for (int j = 0; j < N ; j++)
    {
        kyori=kyori+L[j];/* code */
        kaisuu=j+1;
        if (kyori>X)
        {   
            cout << kaisuu;
            break;/* code */
        }else{
            if(kaisuu==N){
                cout << kaisuu+1;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz(a) ((int) (a).size())
#define nl '\n'
#define sp ' '
#define f first
#define s second

#define MAXN 1005

int N, M, bestInd[1 << 3];
ll A[MAXN][3], ans[1 << 3][2], best[1 << 3];
bool taken[MAXN][1 << 3];

int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) cin >> A[i][j];
        for (int j = 0; j < (1 << 3); j++) taken[i][j] = false;
    }
    for (int i = 0; i < (1 << 3); i++) for (int j = 0; j < 2; j++) ans[i][j] = 0;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < (1 << 3); j++) {
            best[j] = -0x3f3f3f3f3f3f3f3f;
            bestInd[j] = -1;
        }
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < (1 << 3); k++) {
                if (taken[j][k]) continue;
                ll val = 0;
                for (int m = 0; m < 3; m++) {
                    if ((k >> m) & 1) val += A[j][m];
                    else val -= A[j][m];
                }
                if (best[k] < val) {
                    best[k] = val;
                    bestInd[k] = j;
                }
            }
        }
        for (int k = 0; k < (1 << 3); k++) {
            taken[bestInd[k]][k] = true;
            ans[k][0] += best[k];
            ans[k][1] = abs(ans[k][0]);
        }
    }
    ll bestAns = 0;
    for (int k = 0; k < (1 << 3); k++) bestAns = max(bestAns, ans[k][1]);
    cout << bestAns << nl;
    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair

void solve (int u) {

    ll n, w;
    cin >> n >> w;

    vector <ll> a (w + 1);

    for (ll i = 0; i < n; ++i) {
        ll t1, t2;
        cin >> t1 >> t2;

        for (ll k = w - t1; k >= 0; --k) {
            a[k + t1] = max(a[k + t1], a[k] + t2);
        }
    }

    ll r = 0;
    for (int i = 0; i <= w; ++i) {
        r = max(r, a[w]);
    }

    cout << r << "\n";

//    cout << "Case #" << k << ": " << count << "\n";

}

int main () {

    ios::sync_with_stdio(0);
    cin.tie(0);

    //int t;
    //cin >> t;
    //int k = 1;
    //while (t--) {
    //    solve(k);
    //    k++;
    //}

    solve(0);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a,b;
ll ans;
ll x[1000001];
ll now;

int main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;i++)
    cin>>x[i];
  now = x[0];
  
  for(int i=1;i<n;i++){
    ans += min(a*(x[i]-now),b);
    now = x[i];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main()
{
  int n, m, a;
  cin >> n >> m;
  ll ans = 0;
  priority_queue<int> q;
  rep(i, n)
  {
    cin >> a;
    q.push(a);
  }
  
  rep(i, m)
  {
    a = q.top();
    q.pop();
    q.push(a / 2);
  }
  
  rep(i, n)
  {
    a = q.top();
    q.pop();
    ans += a;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
/*
int stoi(string sstoi){//string->int
  ll int stois=0;
  rep(stoii,0,sstoi.length()){
    stois+=ctoi(sstoi[stoii])*jo(10,sstoi.length()-stoii-1);
  }
  return stois;
}*/
  
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int x;
  cin>>x;
  int max=1;
  rep(i,2,ceil(sqrt(x))+1){
    for(int j=1;jo(i,j)<=x;j++){
      if(jo(i,j)>max) max=jo(i,j);
    }
  }
  cout<<max;
  
    
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示


Measured memory_bytes: 256
N = gets.to_i
F = []
N.times{
  F << gets.chomp.delete(' ').to_i(2)
}
P = []
N.times{
  P << gets.chomp.split(" ").map(&:to_i)
}

ans = (1...(1<<10)).to_a.map{|i|
  tmp = 0
  (0...N).each{|j|
    wk = F[j] & i
    idx = (0...10).count{|k| wk[k] == 1}
    tmp += P[j][idx]
  }
  tmp
}

puts ans.max


Measured memory_bytes: 1788
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int i, x;
	for (i = 1; ; i++) {
		scanf("%d ", &x);
		if (x == 0) break;
		printf("Case %d: %d\n", i, x);
	}
	return 0;
}

Measured memory_bytes: 604
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from itertools import accumulate
a=list(accumulate(a))
b=list(accumulate(b))
from bisect import bisect_right
ans=bisect_right(b,k)
for i in range(n):
  if a[i]>k:break
  ans=max(ans,i+1+bisect_right(b,k-a[i]))
print(ans)


Measured memory_bytes: 40624