akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

#define DMAX 100100
#define NMAX 
#define MMAX 

using namespace std;

long long n, k, x[DMAX], v[DMAX], s[DMAX], c, s2[DMAX], ans;

priority_queue<long long> mx;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> c;
	for(long long i = 1; i <= n; i++) {
		cin >> x[i] >> v[i];
	}	

	for(long long i = 1; i <= n; i++)
		s[i] = s[i - 1] + v[i];

	for(long long i = 1; i <= n; i++)
		s[i] -= x[i];


	for(long long i = n; i > 0; i--)
		s2[i] = s2[i + 1] + v[i];

	for(long long i = 1; i <= n; i++)
		s2[i] -= c - x[i];

	for(int i = 1; i <= n; i++)
		ans = max({ans, s[i], s2[i]});

	mx.push(0); // 

	// dbg_v(s, n + 1);
	// dbg_v(s2, n + 1);

	for(long long i = 1; i <= n; i++) {
		if(i > 1)
			mx.push(s[i - 1]);

		ans = max(s2[i] - (c - x[i]) + mx.top(), ans);
	}

	while(!mx.empty()) mx.pop();
	mx.push(0);

	for(long long i = n; i > 0; i--) {
		if(i < n)
			mx.push(s2[i + 1]);

		//ans = max(s2[i] - (c - x[i]) + mx.top(), ans);
		ans = max(s[i] - x[i] + mx.top(), ans);
	}

	cout << ans << '\n';
}

Measured memory_bytes: 4600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if(s>=t){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3636
package main
 
import (
	"fmt"
)
 
func main() {
	var a int
	var b int
	var o = 0
	fmt.Scan(&a, &b)
	if a <= b {
		o = 0
	}else if a <= b * 2 {
		o = 0
	}else {
		o = a - b * 2
	}
	fmt.Print(o)
}

Measured memory_bytes: 512
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<int,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
vector<tint> ed;
vector<pint> v,w;
int main()
{
	int n,x,y,out=0;
	cin>>n;
	rep(i,n){
		cin>>x>>y;
		v.pb(mp(x,i));w.pb(mp(y,i));
	}
	sort(All(v));sort(All(w));
	rep(i,n-1){
		ed.pb(mp(v[i+1].fi-v[i].fi,mp(v[i].se,v[i+1].se)));
		ed.pb(mp(w[i+1].fi-w[i].fi,mp(w[i].se,w[i+1].se)));
	}
	sort(All(ed));
	unionf uni(n+10);
	rep(i,ed.size()){
		x=ed[i].se.fi;y=ed[i].se.se;
		if(uni.finds(x,y)) continue;
		out+=ed[i].fi;
		uni.unions(x,y);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void out(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void out(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);out<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';out<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T *a,int n){REP(i,n){if(i)cout<<',';cout<<a[i];}cout<<endl;}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>void output(T t){if(t<0)t=-t,putchar(45);static int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;putchar(c[--k]^48));}
template<class S,class ...T>void output(S a,T...t){output(a);putchar(' ');output(t...);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());t=10*t+c-48);t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

int a[10010];
int b[10010];

int main() {
  int n,m;
  while(cin>>n>>m) {
    REP(i,n) cin >> a[i] >> b[i];
    int mx = m;
    bool ng = 0;
    REP(i,n) {
      m += a[i]-b[i];
      chmax(mx,m);
      ng |= m < 0;
    }
    cout << (ng?0:mx) << endl;
  }
}

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

int main(){
    int n,x,m;
    cin>>n>>x;
    int mn=x;
    for(int i=0;i<n;i++){
        cin>>m;
        x-=m;
        mn=min(mn,m);
    }
    cout<<n+x/mn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;cin>>s;
  for(int i=0;i<(int)s.size()-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,A,B;cin>>N>>A>>B;
    if((B-A)%2==0)cout<<(B-A)/2<<endl;
    else{
        cout<<min(A+(B-A-1)/2,N-B+1+(B-A-1)/2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
long long int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       long long int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int main()
    {
        std::ios::sync_with_stdio(false);
       int a,b,c,d;
       cin>>a>>b>>c>>d;
       int f=0;
      for(int i=0;;i++)
       {

           if(i%2==0)
           {
               c-=b;
           }
           else
            a-=d;
          // cout<<a<<" "<<c<<endl;

           if(c<=0)
            {


                break;
            }
           if(a<=0)
           {

               break;
           }
       }
       if(c<=0 || (a<=0 && c<=0))
        cout<<"Yes"<<endl;
       else
        cout<<"No"<<endl;
        return 0;
    }


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

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

void solve()
{
	int n, m;
	cin>>n>>m;
	int answer = n;
	for(int i=0; i<m; i++)
	{
		int t;
		cin>>t;
		answer -= t;
	}
	if(answer < 0)
		answer  = -1;
	cout<<answer<<"\n";
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

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

    vector< vector<int> > v1(n), v2(n);
    for(int i = 0 ; i < n ; ++i){
        int r, c;
        cin >> r >> c;
        --r;
        --c;
        v1[r].emplace_back(c);
        v2[c].emplace_back(r);
    }

    for(int i = 0 ; i < n ; ++i){
        if((int)v1[i].size() > 1 || (int)v2[i].size() > 1){
            cout << -1 << endl;
            return 0;
        }
    }

    int ans = 0;
    for(int i = 0 ; i < n ; ++i){
        if(v1[i][0] == i){
            continue;
        }
        ++ans;
        int r = v2[i][0];
        int c = v1[i][0];
        swap(v1[i][0], v1[r][0]);
        swap(v2[i][0], v2[c][0]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13580
//
// Created by  on 28.01.2018.
//



#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <iomanip>
//defines
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double

const int N = int(1e5+1), mod = int(1e9)  + 7;
//functions
using namespace std;



int ar[2][111];
int n;
int tr(int i,int j){
    if(i>2 or j>n){
        return 0;
    }
    //else{
        return max(tr(i+1,j)+ar[i][j],tr(i,j+1)+ar[i][j]);

}
int main(){
//#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//#endif
    cin>>n;
    for(int i = 1; i<=2; i++){
        for(int j = 1; j<=n; j++){
            cin>>ar[i][j];
        }
    }
    cout<<tr(1,1);
    return 0;
}




Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B;

int main() {
  INCANT;
  cin >> A >> B;
  cout << A+B/2 << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = max(a*b, c*d);
	cout << ans << endl;
}


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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll t=1;
	//cin >> t;
	while(t--)
	{
		ll n,ma=0,ans=0;
		cin>>n;
		ll a[n];
		lp(i,0,n-1){
			cin>>a[i];
			ma=max(ma,a[i]);
		}
		bool div[ma+1]={0};
		sort(a,a+n);
		lp(i,1,n-1){
			if(a[i]==a[i-1])
				div[a[i]]=1;
		}
		lp(i,0,n-1){
			for(ll j=2*a[i]; j<=ma; j+=a[i])
				div[j]=1;
		}
		lp(i,0,n-1)
			if(!div[a[i]])
				ans++;
		cout<<ans<<endl;
		
	}
	return 0;	
}


Measured memory_bytes: 6132
#AGc008B

n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
w=[0 for i in xrange(n+1)]
b=[0 for i in xrange(n+1)]

for i in xrange(n):
 w[i+1]=w[i]+a[i]
 b[i+1]=b[i]+max(0,a[i])

res=0
for i in xrange(n-k+1):
 x=(b[i]-b[0])+(b[n]-b[i+k])
 y=x+(w[i+k]-w[i])
 res=max(res,x,y)

print res


Measured memory_bytes: 12244
from math import gcd

def match(a, b, c):
    if a == b == c:
        return a
    if a == b or b == c:
        return gcd(gcd(a, b), c) * 3
    return gcd(gcd(a, b), c) * 6

def main():
    K = int(input())
    answer = 0

    for a in range(1, K+1):
        for b in range(a, K+1):
            for c in range(b, K+1):
                answer += match(a, b, c)
    print(answer)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

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

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

typedef long long ll;

using namespace std;

struct edge{int to,cap,rev;};

class FF
{
public:
  vector<vector<edge>>G;
  vector<bool> used;
  FF(int maxv)
  {
    G.resize(maxv);
    used.resize(maxv);
  }
  void add_edge(int from,int to,int cap,bool directed=1)
  {
    G[from].push_back({to,cap,(int)G[to].size()});
    G[to].push_back({from,cap*(!directed),(int)G[from].size()-1});
  }
  int dfs(int v,int t,int f)
  {
    if(v==t)return f;
    used[v]=1;
    for(auto &nv:G[v])
    {
      if(!used[nv.to] && nv.cap>0)
      {
        int d=dfs(nv.to,t,min(f,nv.cap));
        if(d>0)
        {
          nv.cap-=d;
          G[nv.to][nv.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
  int solve(int s,int t)
  {
    int res=0;
    while(1)
    {
      for(int i=0;i<used.size();i++)used[i]=0;
      int f=dfs(s,t,(1<<30)-1);
      if(f==0)break;
      res+=f;
    }
    return res;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;
  cin>>h>>w;
  vector<string>hw(h);
  rep(i,h)cin>>hw[i];
  int s,t;
  FF ff(h*w*2);
  rep(i,h*w)
  {
    ff.add_edge(i*2,i*2+1,1,0);
  }
  rep(i,h)
  {
    vector<int>leaf;
    leaf.clear();
    rep(j,w)
    {
      if(hw[i][j]!='.')
      {
        int num=(i*w+j)*2;
        if(hw[i][j]=='S')s=num+1;
        if(hw[i][j]=='T')t=num;
        for(auto k:leaf)
        {
          ff.add_edge(k+1,num,10000,1);
          ff.add_edge(num+1,k,10000,1);
        }
        leaf.push_back(num);
      }
    }
  }
  rep(j,w)
  {
    vector<int>leaf;
    leaf.clear();
    rep(i,h)
    {
      if(hw[i][j]!='.')
      {
        int num=(i*w+j)*2;
        for(auto k:leaf)
        {
          ff.add_edge(k+1,num,10000,1);
          ff.add_edge(num+1,k,10000,1);
        }
        leaf.push_back(num);
      }
    }
  }

  ll res=ff.solve(s,t);
  if(res>=10000)
  {
    res=-1;
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 61952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  
  multiset <int> color;
  color.insert(-1); color.insert(1e9+1);
  rep(i,N) {
    auto k = color.lower_bound(A[i]);
    k--;
    if (k != color.begin()) color.erase(k);
    color.insert(A[i]);
  }
  int ans = color.size();
  cout << ans - 2 << endl;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    for(int n; cin >> n, n;)
	{
		int res = 0;
		while(n != 1)
		{
			if(n % 2 == 0) n /= 2;
			else (n *= 3) += 1;
			res++;
		}
		
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
	
using namespace std;
inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

template<class F, class S> ostream& operator<<(ostream& os, pair<F, S> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template<class T, class S> ostream& operator<<(ostream& os, map<T, S> &v) {
	os << "{";
	for(auto &i : v) cout << "{" << i.first << "," << i.second << "}";
	os << "}";
	return os;
}

template<class T> ostream& operator<<(ostream& os, set<T> &v) {
	os << "{";
	for(auto &i : v) cout << i << ",";
	os << "}";
	return os;
}
 
template<class T> ostream& operator<<(ostream& os, vector<T> &v) {
	os << "[";
	if(v.size()) os << v[0];
	for(int i = 1; i < v.size(); ++i) os << "," << v[i];
	os << "]";
	return os;
}

/*----------------------------------------------------------------------------*/

int main (){
	// FAST_IO();

	int in[3][3];

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

	int n;
	cin >> n;

	while(n-->0) {
		int x;
		cin >> x;

		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (in[i][j] == x) {
					in[i][j] = 0;
				}			
			}
		}	
	}

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


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

	int da = 0, db = 0;
	for (int i = 0; i < 3; ++i) {
		da += in[i][i];
		db += in[2-i][i];
	}

	if (!da || !db) {
		cout << "Yes" << endl;
		return 0;
	} 

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3596
from collections import namedtuple

N = int(input())
ab = [tuple(map(int, input().split())) for i in range(N)]
cd = [tuple(map(int, input().split())) for i in range(N)]

G = [[] for i in range(N * 2 + 2)]

Edge = namedtuple("Edge", ("to", "cap", "rev"))

def add_edge(frm, to, cap):
    G[frm].append(Edge(to, cap, len(G[to])))
    G[to].append(Edge(frm, 0, len(G[frm]) - 1))

# 現在の頂点, 終点, 増加フロー
def dfs(v, t, f):
    if v == t:
        return f
    used[v] = True
    for i, e in enumerate(G[v]):
        if not used[e.to] and e.cap > 0:
            d = dfs(e.to, t, min(f, e.cap))
            if d > 0:
                G[v][i] = Edge(e.to, e.cap - d, e.rev)
                G[e.to][e.rev] = Edge(v, G[e.to][e.rev].cap + d, i)
                return d
    return 0

for i in range(1, N + 1):
    add_edge(0, i, 1)
    add_edge(N + i, N * 2 + 1, 1)

for i in range(1, N + 1):
    a, b = ab[i - 1]
    for j in range(1, N + 1):
        c, d = cd[j - 1]
        if a < c and b < d:
            add_edge(i, N + j, 1)            

flow = 0
while 1:
    used = [False for i in range(N * 2 + 2)]
    f = dfs(0, N * 2 + 1, 114514)
    if f == 0:
        break
    flow += f

print(flow)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007
#define lson(v) ((v)<<1)
#define rson(v) (((v)<<1)^1)
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
int n,a[100];
int main(){
    // inputing start
    scanf("%d",&n);
	int xb,x2,mv[2],mp[2];
	mv[0]=mv[1]=-1;
	for(xb=0;xb<n;++xb){
		scanf("%d",a+xb);
		if(a[xb]>=0){
			if(a[xb]>mv[0]){
				mv[0]=a[xb];
				mp[0]=xb;
			}
		}
		if(a[xb]<=0){
			if(ABS(a[xb])>mv[1]){
				mv[1]=ABS(a[xb]);
				mp[1]=xb;
			}
		}
	}
	printf("%d\n",n*2-1);
	if(mv[0]>=mv[1]){
		for(xb=0;xb<n;++xb){
			printf("%d %d\n",mp[0]+1,xb+1);
		}
		for(xb=1;xb<n;++xb){
			printf("%d %d\n",xb,xb+1);
		}
	}
	else{
		for(xb=0;xb<n;++xb){
			printf("%d %d\n",mp[1]+1,xb+1);
		}
		for(xb=n;xb>1;--xb){
			printf("%d %d\n",xb,xb-1);
		}
	}
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

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

    vector<pair<int,pair<int,int>>>pyi(m);
    rep(i,m){
        int p,y;cin>>p>>y;
        pyi[i]={p,{y,i}};
    }

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

    int cnt=1;
    pyi[0].second.first=1;

    for(int i=1;i<m;i++){
        if(pyi[i].first==pyi[i-1].first){
            cnt++;
            pyi[i].second.first=cnt;
        }
        else {
            cnt=1;
            pyi[i].second.first=1;
        }
    }

    vector<pair<int,pair<int,int>>>P(m);
    rep(i,m){
        P[i].first=pyi[i].second.second;
        P[i].second.first=pyi[i].first;
        P[i].second.second=pyi[i].second.first;
    }

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

    rep(i,m){
        printf("%06d%06d\n",P[i].second.first,
               P[i].second.second);
    }
}


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

const int MAX_H = 50;
const int MAX_W = 50;

int h, w;

int board[MAX_H][MAX_W];
int dp[MAX_H][MAX_W];

int main() {
	char ch;
	std::cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			std::cin >> ch;
			board[i][j] = atoi(&ch);
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i < h; ++i)
		dp[i][0] += dp[i - 1][0] + board[i][0];
	for (int i = 1; i < w; ++i)
		dp[0][i] += dp[0][i - 1] + board[0][i];
	for (int i = 1; i < h; ++i) {
		for (int j = 1; j < w; ++j) {
			dp[i][j] = std::min(dp[i - 1][j], dp[i][j - 1]) + board[i][j];
		}
	}
	std::cout << dp[h - 1][w - 1] << std::endl;
	return 0;
}

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

using namespace std;

int main(){
    vector<int> vec(3);
    for(auto& a:vec){
        cin >> a;
    }
    sort(vec.begin(),vec.end());
    if(vec[0]+vec[1]==vec[2])
        cout << "Yes"<< endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main()
{
  vector<long long> v(3, 0);
  cin >> v[0] >> v[1] >> v[2];

  sort(v.begin(), v.end());
  
  if (v[0] == 5 && v[1] == 5 && v[2])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin>>n;
    vector<int> cnt(50,0),v(n);
    rep(i,n){
        cin>>v[i];
    }
    rep(i,n){
        for(int j = 0; j < 50; j++){
            if(v[i]&(1<<j))cnt[j] += 1;
        }
    }
    rep(i,50){
        if(cnt[i]%2!=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 640
#include<iostream>

int main() {
	int d, g;
	std::cin >> d >> g;

	int *p = new int[d];
	int *c = new int[d];

	for (int i = 0; i < d; i++) {
		std::cin >> p[i] >> c[i];
	}

	int ans = 1 << 30, temp = 0, temp2 = 0, step = 0, step2 = 0;
	for (int i = 0; i < 1 << d; i++) {
		temp = 0, temp2 = 0, step = 0, step2 = 0;

		for (int j = 0; j < d; j++) {
			if ((i & 1 << j) != 0) {
				temp += (j + 1) * 100 * p[j] + c[j];
				step += p[j];
			}
		}

		if (temp - g < 0) {
			for (int j = d - 1; j >= 0; j--) {
				temp2 = temp;
				step2 = step;
				if ((i & 1 << j) == 0) {
					for (int k = 0; k < p[j]; k++) {
						temp2 += (j + 1) * 100;
						step2++;
						if (temp2 - g >= 0)break;
					}
				}
				if (temp2 - g >= 0) {
					temp = temp2;
					step = step2;
					break;
				}
			}
		}
		if (ans > step&&temp - g >= 0)ans = step;
	}

	printf("%d", ans);
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

#入力終わり


#累積和とる

A_wa = [0]
for i in range(N) :
    A_wa.append(A_wa[i]+A[i])

B_wa = [0]
for i in range(M) :
    B_wa.append(B_wa[i]+B[i])

a = N
ans = 0
for b in range(M+1):
  A_lim = K - B_wa[b]
  if A_lim < 0:
    break
  while A_wa[a] > A_lim and a > 0:
    a -= 1
  ans = max(a + b, ans)
print(ans)
  


Measured memory_bytes: 47464
#include<bits/stdc++.h>
using namespace std;
string S;
int main(){
  cin>>S;
  bool n=0,w=0,s=0,e=0;
  for(int i=0;i<S.length();i++){
    if(S[i]=='N')n=1;
    if(S[i]=='S')s=1;
    if(S[i]=='W')w=1;
    if(S[i]=='E')e=1;
  }
  if(n==1 && s==1 && w==1 && e==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(n==1 && s==1 && w==0 && e==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(n==0 && s==0 && w==1 && e==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
var h = [],hs = 0;
h[0] = new Array(2);
h[0][0] = -1;h[0][1] = -1;
 
function insert(key){
    h[++hs] = key;
 
    var i = hs;
 
    while(h[i][1] < h[Math.floor(i / 2)][1]){
        var ex = h[i];
        h[i] = h[Math.floor(i / 2)];
        h[Math.floor(i / 2)] = ex;
        i = Math.floor(i / 2);
    }
}
 
function extract(){
    if(hs <= 0)
        return;
 
    var ret = h[1];
 
    h[1] = h[hs--];
 
    i = 1;
    while((i * 2 <= hs && h[i][1] > h[i * 2][1]) || (i * 2 + 1 <= hs && h[i][1] > h[i * 2 + 1][1])){
        var l = i * 2;var r = i * 2;
        if(i * 2 + 1 <= hs)
            r++;
        var m = h[l][1] <= h[r][1] ? l : r;
        var ex = h[i];
        h[i] = h[m];
        h[m] = ex;
        i = m;
 
    }
    return ret;
}


function Main(input){
    input = input.split("\n");
    var n = parseInt(input[0],10);

    var graph = [];

    for(var i = 0;i < n;i++){
        graph[i] = new Array(n);
        input[i + 1] = input[i + 1].split(" ");
        for(var j = 0;j < n;j++){
            graph[i][j] = parseInt(input[i + 1][j + 1],10);
        }
    }

    var ans = [];

    for(var i = 0;i < n;i++){
        ans[i] = new Array(n);
        for(var j = 0;j < n;j++){
            ans[i][j] = -1;
        }
    }

    var count = 1;
    var fin = Array(n);
    for(var i = 0;i < n;i++)
        fin[i] = false;
    fin[0] = true;
    for(var i = 0;i < n;i++){
        if(graph[0][i] > -1){
            var a = [];a[0] = i;a[1] = graph[0][i];a[2] = 0;
            insert(a);
        }
    }

    while(count < n){
        var aa = extract();
        if(fin[aa[0]])
            continue;

        fin[aa[0]] = true;
        ans[aa[0]][aa[2]] = ans[aa[2]][aa[0]] = aa[1];
        count++;

        for(var i = 0;i < n;i++){
            if(graph[aa[0]][i] > -1){
                var a =[];a[0] = i;a[1] = graph[aa[0]][i];a[2] = aa[0];
                insert(a);
            }
        }
    }

    var sum = 0;

    for(var i = 0;i < n;i++){
        for(var j = 0;j < n;j++){
            if(i < j && ans[i][j] > -1)
                sum += ans[i][j];
        }
    }
    console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 18072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int kounyu(int h, int y, int k)
{
	int nedan=0;
	while(k>0)
	{
		nedan += y;
		k -= h;
	}
	return nedan;
}
int main(void)
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	int ans = min(kounyu(A, B, N), kounyu(C, D, N));
	cout << ans << endl;
}



Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,ans=0,a;
  cin >> n;
  for(int i=1; i<=1000000; i++) {
    if(n%i==0) {
      a=n/i-1;
      if(a>i) {
        ans+=a;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  //  ll p=100;
    //while(p--){
   ll n,x,c=0;
   cin>>n>>x;
   ll a[n];
   for(int i=0;i<n;i++)
    cin>>a[i];
   for(int i=1;i<n;i++)
   {
       if(a[i]+a[i-1]>x)
       {
           ll p=a[i]+a[i-1]-x;
           c+=p;
           if(p>a[i])
           {
               a[i]=0;
               a[i-1]-=(p-a[i]);
           }
           else{
            a[i]-=p;
           }
       }
   }
   cout<<c<<endl;
}






Measured memory_bytes: 4300
// ABC058
// A - ι⊥l
#include<bits/stdc++.h>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
float n,x,t;
int ans;
using namespace std;
int main()
{
  //freopen("xxx.in","r",stdin);
  //freopen("xxx.out","w",stdout);
  cin>>n>>x>>t;
  ans=int(ceil(n*1.0/x)*t);
  cout<<ans<<endl;
  //fclose(stdin);
  //fclose(stdout);
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long double
//template

//main
signed main(){
  int a,b;cin>>a>>b;
  a=1/a;b=1/b;
  a+=b;
  a=1/a;
  cout<<fixed<<setprecision(12)<<a<<endl;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll a,b,v,w,t; cin >> a >> v >> b >> w >> t;
        ll x = abs(a-b);
        ll y = (v-w)*t;
        cout<<(x<=y ? "YES" : "NO")<<endl;


return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;
ll dp[2005][2005]={0};
int a[2005],b[2005];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++)
        cin>>b[i];
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<=m;i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            if(a[i]==b[j])
            {
                dp[i][j]+=dp[i-1][j-1]+1;
            }
            dp[i][j]%=MOD;

        }


    }
    if(dp[n][m]<0) dp[n][m]+=MOD;
    cout<<(dp[n][m]+1)%MOD;



}


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

int T[8][8],x[8]={0,0,1,-1,1,1,-1,-1},y[8]={1,-1,0,0,1,-1,1,-1};
/*
void P(){
 for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      if(T[i][j]==0)cout<<'o';
      else if(T[i][j]==1)cout<<'x';
      else cout<<'.';
    }
    cout<<endl;
  }
}
*/
int count(int a,int b,int muki,int f)
{
  int c=0;
  while(1){
    a+=x[muki];b+=y[muki];
    if(a<0 || b<0 || a>7|| b>7){
      c=0;
      break;
    }
    if(T[a][b]==2){
      c=0;
      break;
    }
    if(T[a][b]==f)break;
    c++;
  }
  return c;
}

void move(int a,int b,int muki,int f)
{
  int flag=0,aa=a,bb=b;
  while(1){
    a+=x[muki];b+=y[muki];
    if(a<0 || b<0 || a>7|| b>7)break;
    if(T[a][b]==2)break;
    if(T[a][b]==f){
      flag=1;
      break;
    }
  }
  if(flag==0)return;
  while(1){
    aa+=x[muki];bb+=y[muki];
    if(aa<0 || bb<0 || aa>7|| bb>7)break;
    if(T[aa][bb]==2)break;
    if(T[aa][bb]==f)break;
    T[aa][bb]=f;
  }
} 
int main()
{
  char c;
  int mk,ki,kj,mc,ci,cj,sum;

  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cin>>c;
      if(c=='o')T[i][j]=0;
      else if(c=='x')T[i][j]=1;
      else T[i][j]=2;
    }
  }
  
  while(1){
    mk=0;ki=-1;kj=-1;
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	if(T[i][j]==2){
	  sum=0;
	  for(int k=0;k<8;k++){
	    sum+=count(i,j,k,0);
	  }
	  if(mk<sum){
	    mk=sum;
	    ki=i;
	    kj=j;
	  }	
	}
      }
    }
    if(mk>0){
      T[ki][kj]=0;
      for(int i=0;i<8;i++)move(ki,kj,i,0);
    }
    //P();
    mc=0;ci=-1;cj=-1;
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++){
	if(T[i][j]==2){
	  sum=0;
	  for(int k=0;k<8;k++){
	    sum+=count(i,j,k,1);
	  }
	  if(mc<=sum){
	    mc=sum;
	    ci=i;
	    cj=j;
	  }	
	}
      }
    }
    if(mc>0){
      T[ci][cj]=1;
      for(int i=0;i<8;i++)move(ci,cj,i,1);
    }
    //P();
    if(mk==0 && mc==0)break;
  }

  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      if(T[i][j]==0)cout<<'o';
      else if(T[i][j]==1)cout<<'x';
      else cout<<'.';
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 1136
#include<iostream>

using namespace std;

int prime(int n)
{
	int i;
	if (n == 2)return 1;
	for (i = 2; i*i <= n; i++)
	{
		if (n%i == 0)return 0;
	}
	return 1;
}

int main()
{
	int n, i, a, count = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		count += prime(a);
	}
	cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ns[][] = new int[n][n];
        int ms[][] = new int[m][m];
        for (int y = 0;y < n;++y){
            String s = sc.next();
            for (int x = 0;x < n;++x){
                ns[x][y] = s.charAt(x) == '#' ? 1 : 0;
            }
        }
        for (int y = 0;y < m;++y){
            String s = sc.next();
            for (int x = 0;x < m;++x){
                ms[x][y] = s.charAt(x) == '#' ? 1 : 0;
            }
        }
        for (int y = 0;y <= n - m;++y){
            for (int x = 0;x <= n - m;++x){
                boolean flag = true;
                for (int y2 = 0;y2 < m;++y2){
                    for (int x2 = 0;x2 < m;++x2){
                        if(ns[x + x2][y + y2] != ms[x2][y2]) {
                            flag = false;
                            break;
                        }
                    }
                    if(!flag)break;
                }
                if(flag) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }


}

Measured memory_bytes: 21588
s=input()
K=int(input())
ns=len(s)
ls=list(s)
for i in range(ns):
    if K==0:
        break
    if ls[i]=="a":
        continue
    toa=ord("z")+1-ord(ls[i])
    #print("toa",toa)
    if toa<=K:
        ls[i]="a"
        #K-=(ord("z")+1-ord(s[i]))
        K-=toa
        #print("K",K)
ls[-1]=chr(ord(ls[-1])+K%26)
#ans=str(ls)
ans="".join(ls)
print(ans)


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

int main() {
  int n,ans=0;
  cin >> n;
  vector<int> l(n);
  rep(i,n) {
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      for (int k=j+1;k<n;++k) {
        bool flag = true;
        if(l[k]>=l[i]+l[j]) {
          continue;
        }
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


vector<ll> inv,fac;

void inverse(ll n){
    //要素数:n+1 (0~n)
    inv[0]=1;
    inv[1]=1;
    for(ll i=2;i<=n;i++){
        inv[i]=(MOD-inv[MOD%i]*(MOD/i))%MOD;
    }
}

void inverse_u(ll n){
    //要素数:n+1 (0~n)
    for(ll i=2;i<=n;i++){
        inv[i]=(inv[i]*inv[i-1])%MOD;
    }
}

void factorial(ll n){
    //要素数:n+1 (0~n)
    fac[0]=1;
    fac[1]=1;
    for(ll i=2;i<=n;i++){
        fac[i]=(fac[i-1]*i)%MOD;
    }
}

ll nCr(ll n,ll r){
    return fac[n]*inv[r]%MOD*inv[n-r]%MOD;
}

ll proinverse(ll x,ll m){
    ll res=1,M=m-2;
    while(M>0){
        if(M&1) res=res*x%m;
        x=x*x%m;
        M>>=1;
    }
    return res;
}

void init_nCr(ll n){
    inv.assign(n+1,0);
    fac.assign(n+1,0);
    inverse(n); inverse_u(n);
    factorial(n);
}

int main(){
    int n,t,ans=0; cin>>n>>t;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    int b=0;
    set<int> s; s.insert(a[0]);
    for(int i=1;i<n;i++){
        b=max(b,a[i]-*begin(s));
        s.insert(a[i]);
    }
    set<int> S;
    rep(i,n){
        if(S.count(a[i]-b)) ans++;
        S.insert(a[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 13024
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a;
    cin>>a;
    vector<int> vec(a);
    rep(i,a){
        cin>>vec.at(i);
    }
    long long min=vec.at(0);
    long long ans=0;
    rep(i,a){
        if(min>=vec.at(i)){
            ans++;
            min=vec.at(i);
        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	if(a*b>c*d){
    	cout << a*b << endl;
    }
  	else{
    	cout << c*d << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void program(); int main() {cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); program();}
#define int long long
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>

#define N 200007
int a[N], h[N], dp[N], st[4*N];
int n;

int Max(int x, int ss, int se, int qs, int qe) {
    if (ss > qe || se < qs) return 0;
    if (ss >= qs && se <= qe) return st[x];

    int m = (ss+se)/2;
    return max(Max(2*x, ss, m, qs, qe),
               Max(2*x+1, m+1, se, qs, qe));
}

int Set(int x, int ss, int se, int q, int v) {
    if (ss > q || se < q) return st[x]; 
    if (ss == se) return st[x] = v;

    int m = (ss+se)/2;
    return st[x] = max(Set(2*x, ss, m, q, v),
                       Set(2*x+1, m+1, se, q, v));
}

void program(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>h[i];
    for(int i=1;i<=n;i++) cin>>a[i];

    int ans = 0;
    for(int i=n;i>=1;i--){
        dp[i] = a[i] + Max(1,1,n,h[i],n);
        Set(1,1,n,h[i],dp[i]);
        ans = max(ans, dp[i]);
    }
    cout<<ans<<endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-different perspective?
-bruteforce?
-greedy?
-reduce dimensionality with problem contraints?
*/


Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

string s;

int main() {
    cin >> s;

    int n = s.size();
    int ans = n;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] != s[i + 1]) {
            int x = max(i + 1, n - i - 1);
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline
n=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))

ans=0
def ab_check(list_count,i):
    ok=-1
    ng=n
    B=b[i]
    while ng-ok>1:
        mid=(ok+ng)//2
        if list_count[mid]<B:
            ok=mid
        else:
            ng=mid
    #print(ok+1,'A')
    return ok+1

def bc_check(list_count,i):
    ok=n
    ng=-1
    B=b[i]
    while ok-ng>1:
        mid=(ok+ng)//2
        if list_count[mid]>B:
            ok=mid
        else:
            ng=mid
    #print(n-ok,'B')
    return n-ok
    #print(i,ok)

for i in range(n):
    ans+=ab_check(a,i)*bc_check(c,i)
print(ans)
#print(a,c,sep='\n')

Measured memory_bytes: 23472
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    int N = S.size();
    map<int, int> mp;
    rep(i,N)mp[S[i]-'a']++;
    ll ans = INF;
    rep(i,26){
        if(!mp.count(i))continue;
        string pre = S;
        string nxt = "";
        ll cnt = 0;
        while(true){
            bool ok = true;
            nxt = "";
            int M = pre.size();
            rep(j,M-1){
                if(pre[j]-'a' != i || pre[j+1] - 'a' != i)ok = false;
                /*calc*/
                if(pre[j]-'a' == i || pre[j+1] - 'a' == i){
                    nxt.push_back(char('a'+i));
                }
                else nxt.push_back(pre[j]);
            }
            if(ok)break;
            cnt++;
            swap(pre, nxt);
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256