akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    int a=0,b=0;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '+'){
            printf("%d\n",a+b);
        }else if(op == '-'){
            printf("%d\n",a-b);
        }else if(op == '*'){
            printf("%d\n",a*b);
        }else if(op == '/'){
            printf("%d\n",a/b);
        }else if(op == '?'){
            break;
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    set<int> s;
    s.insert(a);
     s.insert(b);
      s.insert(c);
      if(s.size()==2)
      cout<<"Yes";
      else
      cout<<"No";

    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,x; cin>>n>>x;
  vi a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      ll d = a[i+1]+a[i]-x;
      a[i+1]=max(0LL,a[i+1]-d);
      ans+=d;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから
void solve(){
  string s,t;
  cin>>s>>t;
  int n=s.size(),m=t.size();
  string ans="";
  rep(i,n)ans+=string{char('z'+1)};
  string bad=ans;
  rep(i,n-m+1){
    bool ng=false;
    string ss=s;
    rep(j,m){
      if(s[i+j]!='?'){
        if(s[i+j]!=t[j])ng=true;
      }
    }
    if(!ng){
      rep(j,m){
        ss[i+j]=t[j];
      }
      rep(j,n){
        if(ss[j]=='?')ss[j]='a';
      }
      chmin(ans,ss);
    }
  }
  if(bad!=ans)cout<<ans;
  else cout<<"UNRESTORABLE";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int N;
vll A;
vll S;

int main(int argc, const char * argv[]) {
    cin >> N;
    A = vll(N);
    S = vll(N);
    for (int n=0; n<N; ++n){
        cin >> A[n];
    }
    S[0] = A[0];
    for (int n=1; n<N; ++n) {
        S[n] = S[n-1]+A[n];
    }
    
    ll Ans = INFLL;
    ll P[4];
    
    for (int q=1; q<N-2; ++q) {
        long p = upper_bound(S.begin(), S.end(), S[q]/2) - S.begin() - 1;
        if (p<0 || (abs(S[q]-S[p] - S[p]) > abs(S[q]-S[p+1] - S[p+1]) && p<q-1) ) p++;
        P[0] = S[p];
        P[1] = S[q]-S[p];
        long r =upper_bound(S.begin(), S.end(), S[q] + (S[N-1]-S[q])/2) - S.begin() - 1;
        if (r<=q || (abs(S[N-1]-S[r] - (S[r]-S[q])) > abs(S[N-1]-S[r+1] - (S[r+1]-S[q])) && r<N-2)) r++;
        P[2] = S[r]-S[q];
        P[3] = S[N-1]-S[r];
        ll Max = *max_element(P, P+4);
        ll Min = *min_element(P, P+4);
        ll Tmp = Max - Min;
        if (Ans > Tmp) Ans = Tmp;
    }
    
    cout << Ans << endl;
 
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int h,w,k;cin>>h>>w>>k;
    char m[h][w];
    rep(i,h)rep(j,w)cin>>m[i][j];
    int ans =0;
    rep(bit1,(1<<h))rep(bit2,(1<<w)){
        int cnt =0;
        rep(i,h)rep(j,w){
            if(m[i][j]!='#')continue;
            if(bit1&(1<<i))continue;
            if(bit2&(1<<j))continue;
            cnt++;
        }
        if(cnt==k){
            ans++;
        }
    }
    cout<<ans<<endl;
    // rep(bit,(1<<h)){
    //     int cnt =0;
    //     rep(i,h)rep(j,w){
    //         if(m[i][j]=='#'){
    //             if(bit&(1<<i))continue;
    //             cnt++;
    //         }
    //     }
    //     if(cnt==k)ans++;
    // }
    // rep(bit,(1<<w)){
    //     int cnt =0;
    //     rep(i,h)rep(j,w){
    //         if(m[i][j]=='#'){
    //             if(bit&(1<<j))continue;
    //             cnt++;
    //         }
    //     }
    //     if(cnt==k){
    //         ans++;
    //         cout<<bit<<endl;
    //     }
    // }
    
    // int cnt =0;
    //     rep(i,h)rep(j,w){
    //         if(m[i][j]=='#'){
    //             cnt++;
    //         }
    //     }
    // if(cnt==k)ans++;
        
    // cout<<ans<<endl;
}

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

int main() {
int n;
  cin >> n;
  vector<int> w(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> w.at(i);
    sum+=w.at(i);
  }
  int suma=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    suma+=w.at(i);
    a.at(i)=abs(2*suma-sum);
  }
  sort(a.begin(),a.end());
  cout << a.at(0) << endl;
}



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

int main()
{
    ll k, a, b, cost = 0, ans = 1;
    cin >> k >> a >> b;

    if (a + 2 >= b)
    {
        cout << 1 + k << endl;
        return 0;
    }

    while (k != 0)
    {
        if (k < 2)
        {
            ans += k;
            break;
        }
        if (ans < a)
        {
            ans++;
            k--;
        }
        else
        {
            ans -= a;
            ans += b;
            k -= 2;
        }
    }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

double setX(double r, double d)
{
	return r*cos(M_PI/2-d);
}

double setY(double r, double d)
{
	return r*sin(d+M_PI/2);
}

int main (void)
{
	double x=0.0, y=0.0, r=0.0, d=0.0, old_d=0;
	
	do
	{
		scanf("%lf,%lf", &r, &d);
		x+=setX(r, old_d);
		y+=setY(r, old_d);
		old_d+=d*M_PI/180;
	}while(r && d);
	
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int r;
    cin >> r;
    if (r >= 2800) {
        cout << "AGC" << endl;
    } else if (r >= 1200) {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
  
Node root;
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if (z->key < x->key){
      x=x->left;
    }
    else
      x = x->right;
  }
  z->parent = y;
  
  if(y==NIL){
    root = z;
  }
  else if(z->key < y->key){
      y->left = z;
  }
  else y->right = z;
}
 
Node treeSearch(Node u, int k){
while(u != NIL){
    if(u->key == k){
        return u;
    }
    else if(u->key < k){
        u = u->right;
    }
    else {
        u = u->left;
    }
}
return NIL;
}
void inorder(Node u){
if (u !=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
}
void preorder(Node u){
    if(u !=NIL){
printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
    }
}
  
  
int main(){
  int n, i, x;
  char comd[20];
  Node t = NIL;
  scanf("%d", &n);

  t=NIL;
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", comd);
    if ( comd[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( comd[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( comd[0] == 'f' ){
      scanf("%d", &x);
       t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 20436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C,D;cin >> A >> B >> C >> D;
  cout << max(A*B,C*D) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, x, c = 0;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> x;
        if(i % 2 == 1 && x % 2 == 1)c++;
    }
    cout << c << endl;
}


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

int main(){
	int n;
	vector<int> taro,hanako;
	while(cin>>n,n){
		int i,j;
		taro.clear();
		hanako.clear();
		for(i=0;i<n;i++){
			int a;
			cin>>a;
			taro.push_back(a);
		}
		sort(taro.begin(),taro.end());
		for(int i=1;i<=2*n;i++){
			if(!binary_search(taro.begin(),taro.end(),i))
				hanako.push_back(i);
		}
		i=j=0;
		int card=0,turn=1;
		vector<int>::iterator p;
		while(!taro.empty() && !hanako.empty()){
			if(turn){
				p = upper_bound(taro.begin(),taro.end(),card);
				if(p!=taro.end()){
					card = *p;
					taro.erase(p);
					
				}
				else card=0;
			}
			else{
				p = upper_bound(hanako.begin(),hanako.end(),card);
				if(p!=hanako.end()){
					card = *p;
					hanako.erase(p);
				}
				else card=0;
			}
			turn^=1;
		}
		cout<<hanako.size()<<endl;
		cout<<taro.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
from collections import deque
# n = int(input())# ノードの数
n, m = map(int, input().split())

# 隣接リストで格納する
adjl = [[] for _ in range(n+1)]
for i in range(m):  # 隣接関係を受け取る
    a, b = map(int, input().split())
    adjl[a].append(b)
    adjl[b].append(a)

NIL = -1  # 未発見を示す値
d = [-1 for i in range(n+1)]  # 頂点1からの距離を格納するリスト
color = [NIL for i in range(n+1)]  # 未到達かを示すリスト


def bfs(start_node, color_id):  # start_nodeは探索の開始点
    global color, d
    q = deque([start_node])
    d[start_node] = 0
    color[start_node] = color_id
    while len(q) != 0:
        u = q.popleft()
        for v in adjl[u]:
            if color[v] == NIL:
                d[v] = d[u]+1
                color[v] = color_id
                q.append(v)


color_id = 0
for u in range(1, n+1):  # node全てからスタートする
    if color[u] == NIL:
        color_id += 1
        bfs(u, color_id)

colordic = {}
for u in range(1, n+1):
    colordic[color[u]] = True

print(len(colordic)-1)


Measured memory_bytes: 92976
#p = lambda  x: print(x, end=", ")
p = lambda  x: x

s = input()		# 文字列の入力  abcdefg...


if s == "zyxwvutsrqponmlkjihgfedcba":
	print("-1")
	exit(0)


from collections import defaultdict
d = defaultdict(int)

S = "abcdefghijklmnopqrstuvwxyz"
for key in S:
	d[key] = 0


for key in s:
	d[key] += 1

ans=""
for k, v in sorted(d.items(), key=lambda x: x[0]):
	#print(str(k) + ": " + str(v))
	if int(v)==0:
		ans = s + k
		print(ans)
		exit(0)

#print(sorted(d.items()))


stock=""
for i in range(25, -1, -1):
	k = s[i]
	b=""
	p(i)
	p(k)
	for a in stock:
		p(a)
		if k < a:
			if b!="":
				if a < b: b = a
			else:
				b = a
	if b!="":
		ans = s[:i] + b
		print(ans)
		exit(0)
	stock += k
	p(b)
	#print("")
	




#for i in range(26):
#	if s[i] == S[i]:
#		ans += s[i]
#	else:
#		ans = ans[:-1] + S[i]
#		print(ans)
#		exit(0)

print("-1")


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int k;
    cin >> k;
    ll a[k];
    rep(i,k) cin >> a[i];
    reverse(a,a+k);
    ll minans,maxans;
    if(a[0]!=2){
        cout << -1 << endl;
        return 0;
    } 
    minans = 2LL;maxans = 3LL;
    for(int i  = 1;i<k;i++){
        ll max_multiple = (maxans/a[i])*a[i];
        ll min_multiple = ((minans+a[i]-1LL)/a[i])*a[i];
        if(min_multiple>maxans && max_multiple<minans){
            cout << -1 << endl;
            return 0;            
        }
        maxans = max_multiple+a[i]-1LL;
        minans = min_multiple;
    }
    cout << minans << " " << maxans << endl;
}

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

int main()
{
	int A,B;
	cin >> A >> B;
	string S;
	cin >> S;
	bool flag = true;
	rep(i,S.size())
	{
		if (i != A && S[i] == '-') flag = false;
		if (i == A && S[i] != '-') flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, x;
    cin >> n >> x;
    int now = 0;
    int cnt = 1;
    rep(i, n) {
        int l;
        cin >> l;
        now += l;
        if (now <= x) cnt++;
    }
    cout << cnt << endl;
}


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

int n;
const int MAX_N = 100;
int d[MAX_N + 1];
int sum = 0;

int main() {
  cin >> n;
  fill(d, d + n, 0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    d[i] = x;
    sum += x;
  }

  double mean = sum * 1.0 / n;
  int p;

  if ((ceil(mean) - mean) <= (mean - floor(mean))) {
    p = ceil(mean);
  } else {
    p = floor(mean);
  }

  int ans = 0;

  for (int j = 0; j < n; j++)
  {
    ans += pow(p - d[j], 2);
  }
  printf("%d", ans);

  return 0;
}

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

const int INF = 1000000007;
const int MOD = 1000000007;


typedef long long ll;
typedef pair<int, int> pr;

const int PRC = 30;

double dp[100001][PRC + 1];
double e[100001];

int main(){
    for(int i = 0; i <= 100000; i++){
        fill(dp[i], dp[i] + PRC + 1, 0);
    }
    dp[0][0] = 1;
    for(int i = 0; i < 100000; i++){
        for(int j = 0; j < PRC; j++){
            dp[i + 1][j + 1] += dp[i][j] / pow(2, j);
            dp[i + 1][0] += dp[i][j] * (1 - 1 / pow(2, j));
        }
    }
    e[0] = 0;
    for(int i = 1; i <= 100000; i++){
        e[i] = e[i-1];
        for(int j = 0; j < PRC; j++){
            e[i] += dp[i-1][j] / pow(2, j);
        }
    }
    while(true){
        int n;
        scanf("%d", &n);
        if(n == 0) break;
        printf("%.12f\n", e[n]);
    }
    return 0;
}

Measured memory_bytes: 26260
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int cal_max(std::vector<std::vector<int>>& current, const int target_color, int count = 0) {
	std::vector<std::vector<bool>> is_merged(current.size(), std::vector<bool>(current.front().size(), false));
	const auto initial = current[0][0];
	std::stack<std::pair<int, int>>  stack; stack.emplace(0, 0);
	is_merged[0][0] = true;
	while (!stack.empty()) {
		auto top = stack.top(); stack.pop();
		for (auto d = -1; d <= 1; d += 2) {
			if (0 <= top.first + d && top.first + d < current.size() && current[top.first + d][top.second] == initial && !is_merged[top.first + d][top.second]) {
				is_merged[top.first + d][top.second] = true;
				stack.emplace(top.first + d, top.second);
			}
			if (0 <= top.second + d && top.second + d < current[top.first].size() && current[top.first][top.second + d] == initial && !is_merged[top.first][top.second + d]) {
				is_merged[top.first][top.second + d] = true;
				stack.emplace(top.first, top.second + d);
			}
		}
	}
	int result = 0;
	if (count == 5) {
		if (initial != target_color) return 0;
		for (const auto& line : is_merged) for (const auto b : line) if (b) ++result;
		return result;
	}
	else if (count < 4) {
		for (auto c = 1; c <= 6; ++c) if (c != initial) {
			for (auto i = 0; i < current.size(); ++i) for (auto j = 0; j < current[i].size(); ++j) if (is_merged[i][j]) current[i][j] = c;
			result = std::max(result, cal_max(current, target_color, count + 1));
		}
	}
	else {
		for (auto i = 0; i < current.size(); ++i) for (auto j = 0; j < current[i].size(); ++j) if (is_merged[i][j]) current[i][j] = target_color;
		result = std::max(result, cal_max(current, target_color, count + 1));
	}
	for (auto i = 0; i < current.size(); ++i) for (auto j = 0; j < current[i].size(); ++j) if (is_merged[i][j]) current[i][j] = initial;
	return result;
}
int main(){
	while (true) {
		int h, w, c; std::cin >> h >> w >> c; if (h == 0) break;
		std::vector<std::vector<int>> state(h, std::vector<int>(w)); for (auto& line : state) for (auto& cell : line) std::cin >> cell;
		std::cout << cal_max(state, c) << '\n';
	}
}


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


typedef struct node *link;
struct node {
    int item;
    link next;
    link prev;
};

void printList(link);

int main(void) {
    int n, i = 0, data;
    link head = NULL, last = NULL, t;
    char command[12];
    scanf("%d", &n);
    while (i < n) {
        scanf("%s", command);
        if (!strcmp(command, "insert")) {
            scanf("%d", &data);
            t = malloc(sizeof(*t));
            t->item = data;
            t->next = head;
            if (t->next != NULL) t->next->prev = t;
            t->prev = NULL;
            head = t;
            if (t->next == NULL) last = t;
        } else if (!strcmp(command, "delete")) {
            scanf("%d", &data);
            t = head;
            while (t != NULL) {
                if (t->item == data) {
                    if (t->prev != NULL) t->prev->next = t->next;
                    else head = t->next;
                    if (t->next != NULL) t->next->prev = t->prev;
                    else last = t->prev;
                    free(t);
                    break;
                } else t = t->next;
            }
        } else if (!strcmp(command, "deleteFirst")) {
            t = head;
            if (head == last) last = NULL;
            head = head->next;
            if (t->next != NULL) t->next->prev = NULL;
            free(t);
        } else if (!strcmp(command, "deleteLast")) {
            t = last;
            if (last == head) head = NULL;
            last = last->prev;
            if (t->prev != NULL)t->prev->next = NULL;
            free(t);
        } else printf("Invalid Command.\n");
        i++;
    }
    printList(head);
    return 0;
}

void printList(link l) {
    link t = l;
    while (t->next != NULL) {
        printf("%d ", t->item);
        t = t->next;
    }
    if (t != NULL) printf("%d\n", t->item);
}

Measured memory_bytes: 33048
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int N = 1e6 + 5;
int ok[N], fre[N];

void solve() {
   int n; cin >> n;
   int data[n+5];
   for(int i = 1; i <= n; i++) {
     cin >> data[i]; fre[data[i]]++;
   }
   int ans = 0;
   
   for(int i = 1; i <= N-5; i++) {
      if(fre[i]) {
         fre[i]--;
         for(int j = i; j <= N-5; j+=i) {
            if(fre[j]) {
                ok[j] = 1;
            }
         }
         fre[i]++;
      }
   }

   for(int i = 1; i <= n; i++) {
     if(ok[data[i]] == 0) ans++;
   }

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

signed main() {   
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
      solve();
  }
}    


Measured memory_bytes: 20768
#include<bits/stdc++.h>
using namespace std;
const int maxn=319,mod=998244353;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
char s[maxn];int n,f[maxn][maxn][maxn],g[maxn][maxn][maxn];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);reverse(s+1,s+n+1);
	g[0][0][0]=1;s[n+1]='2';
	for(int i=0;i<n;i++) for(int j=0;j<=i;j++) for(int k=0;j+k<=i;k++) if(g[i][j][k])
	{
		int v=s[i-j-k+1]-'0';
		Add(g[i+1][j][k],g[i][j][k]);
		if(v) Add(g[i+1][j+1][k],g[i][j][k]);
		else Add(g[i+1][j][k+1],g[i][j][k]);
	}
	f[n][0][0]=1;
	for(int i=n-1;i;i--) for(int j=0;j<=i;j++) for(int k=0;j+k<=i;k++)
	{
		int va=s[i-j-k+1]-'0',vb=s[i-j-k+2]-'0',nxt[3];
		nxt[0]=j+1;nxt[1]=k;nxt[2]=0;
		if(nxt[va]){nxt[va]--;if(nxt[vb]&&(va==0||vb==0))nxt[vb]--;}
		f[i][j][k]|=f[i+1][nxt[0]][nxt[1]];
		nxt[0]=j;nxt[1]=k+1;nxt[2]=0;
		if(nxt[va]){nxt[va]--;if(nxt[vb]&&(va==1||vb==1))nxt[vb]--;}
		f[i][j][k]|=f[i+1][nxt[0]][nxt[1]];
	}
	int ans=0;
	for(int i=1;i<=n;i++) for(int j=0;j<=i;j++) for(int k=0;j+k<=i;k++)
		if(f[i][j][k]) Add(ans,g[i][j][k]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 118196
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int h,w;
	cin>>h>>w;
    vvi f(h,vi(w));
    rep(i,h)rep(j,w){char c;cin>>c;f[i][j]=c=='#'?1:0;}
    set<int> x,y;
    rep(i,h){int p=0;rep(j,w)p+=f[i][j];if(p==0)y.insert(i);}
    rep(j,w){int p=0;rep(i,h)p+=f[i][j];if(p==0)x.insert(j);}
    rep(i,h){
        if(y.find(i)!=y.end())continue;
        rep(j,w){
            if(x.find(j)!=x.end())continue;
            cout<<(f[i][j]?"#":".");
        }
        cout<<endl;
    }

	return 0;
}


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


int main(){
    int n,m;
    cin >> n >> m;
    vector<bool> tained(n,false);
    vector<int> num(n,1);
    tained[0]=true;
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        num[x]--;
        num[y]++;
        if(tained[x]){
            tained[y]=true;
        }
        if(num[x]==0){
            tained[x]=false;
        }
        for(int j=0;j<n;j++){
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(tained[i])ans++;
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define M 100005
#define LL long long
using namespace std;
int n;
LL A[M],ans[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&A[i]);	
	for(int i=1;i<=n;i++){
		if(i%2==0)ans[1]-=A[i];
		else ans[1]+=A[i];
	}
	for(int i=1;i<n;i++)
		ans[i+1]=A[i]*2-ans[i];
	for(int i=1;i<=n;i++)printf("%lld ",ans[i]);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int K;
    cin >> K;
    int x = 7%K;
    set<int> s;
    int i = 1;
    // while(s.count(x) == 0){//まだ訪れていない場合続ける
    //     if(x==0){
    //         cout << i << endl;
    //         return 0;
    //     }
    //     s.insert(x);
    //     x = (x*10+7)%K;
    //     ++i;
    // }
    for(int i=1; i<=K; i++){
        if(x==0){
            cout << i << endl;
            return 0;
        }
        x = (x*10+7)%K;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}
 
int main()
{
    ll a, b;
    cin >> a >> b;

    cout << (ll)(a*b)/__gcd(a, b) << "\n";
}

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

mod = 1000000007

RGB = [1,0,0]
n_cols = 1
ans = 1

dp=[0]*(N+1)

#A[0]による初期条件
dp[0]=2
dp[1]=1

if A[0]>0:
  print(0)
  exit()
  
for a in A[1:]:
  if a==0:
    n_cols += 1
    dp[0]-=1
    dp[1]+=1
    if n_cols ==4:
      print(0)
      exit()
      
  else:
    if dp[a]==0:
      print(0)
      exit()
    else:
      ans *= dp[a]
      ans %= mod
      dp[a]-=1
      dp[a+1]+=1
      
if n_cols==1:
  ans *= 3
else:
  ans *= 6
ans %=mod
print(ans)

Measured memory_bytes: 14072
import java.math.BigDecimal;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        BigDecimal total = new BigDecimal(0);
        final BigDecimal rate = new BigDecimal(380000.0);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String x = sc.next();
            String u = sc.next();
            if ("JPY".equals(u)) {
                total = total.add(new BigDecimal(x));
            } else {
                total = total.add(new BigDecimal(x).multiply(rate));
            }
        }
        System.out.println(total);
    }
}

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

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

	int count = 0;
	int temp1, temp2;
	for (int i = 0; i < N; i++) {
		cin >> temp1 >> temp2;
		if (temp1 == temp2) {
			count++;
			if (count == 3) {
				cout << "Yes" << endl;
				return 0;
			}
		} else {
			count = 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
// --------------
// Tejas Pandey  |
// 22 - 08 - 20  |
// Atcoder BC 176|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,x,t;
  cin >> n >> x >> t;
  ll req = (n + x - 1)/x;
  cout << req*t << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=44;
const int oo=1e8;
int a[mx],b[mx],c[mx];
int f[44][440][440];
int n,ma,mb;
int solve(int i,int x,int y){
  if(f[i][x][y]!=-1)  return f[i][x][y];
  if(i==n){
    if(x*mb==y*ma && y!=0)return 0;      
    return oo;
  }
  f[i][x][y]=min(solve(i+1,x,y),c[i]+solve(i+1,x+a[i],y+b[i]));
  return f[i][x][y];
}
int main(){
  cin>>n>>ma>>mb;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  memset(f,-1,sizeof f);
  int ans=solve(0,0,0);
  if(ans>=oo)ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 33536
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>

typedef unsigned long long ULL;

const int MAXN = 1010, MAXM = 1010, MAXP = 110;
const ULL B1 = 9973;
const ULL B2 = 100000007;

bool G[MAXN][MAXM], pat[MAXP][MAXM];
ULL hash[MAXN][MAXM], temp[MAXN][MAXM];
int P;

int trans(char ch) {
    if('A' <= ch && ch <= 'Z') return ch - 'A';
    if('a' <= ch && ch <= 'z') return 26 + ch - 'a';
    if('0' <= ch && ch <= '9') return 52 + ch - '0';
    if(ch == '+') return 62;
    return 63;
}

ULL qpow(ULL a, int x) {
    ULL res = 1;
    for(; x; x >>= 1) {
        if(x & 1) res *= a;
        a *= a;
    }
    return res;
}

void calcu_hash(bool (*g)[MAXM], int n, int m) {
    ULL h, t = qpow(B1, P);
    for(int i = 0; i < n; ++i) {
        h = 0;
        for(int j = 0; j < P; ++j)
            h = h * B1 + g[i][j];
        for(int j = 0; j + P <= m; ++j) {
            temp[i][j] = h;
            if(j + P < m)
                h = h * B1 - g[i][j] * t + g[i][j + P];
        }
    }
    t = qpow(B2, P);
    for(int j = 0; j + P <= m; ++j) {
        h = 0;
        for(int i = 0; i < P; ++i)
            h = h * B2 + temp[i][j];
        for(int i = 0; i + P <= n; ++i) {
            hash[i][j] = h;
            if(i + P < n)
                h = h * B2 - temp[i][j] * t + temp[i + P][j];
        }
    }
}

void turn(bool (*g)[MAXM], int n, int m) {
    n = std::max(n, m);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < i; ++j)
            std::swap(g[i][j], g[j][i]);
}

void reverse(bool (*g)[MAXM], int n, int m) {
    int mid = m / 2;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < mid; ++j)
            std::swap(g[i][j], g[i][m - 1 - j]);
}

char buf[MAXN / 6 + 5];

void read(bool (*g)[MAXM], int n, int m) {
    for(int i = 0; i < n; ++i) {
        scanf("%s", buf);
        int l = strlen(buf);
        for(int j = 0; j < l; ++j) {
            int v = trans(buf[j]);
            for(int k = 0; k < 6; ++k, v >>= 1)
                g[i][(j + 1) * 6 - 1 - k] = v & 1;
        }
    }
}


std::multiset<ULL> lib;
int main() {
    int W, H;
    while(~scanf("%d%d%d", &W, &H, &P) && (W + H + P)) {
        memset(G, 0, sizeof(G));
        memset(pat, 0, sizeof(pat));
        read(G, H, W);
        read(pat, P, P);
        for(int i = 0; i < 4; ++i) {
            calcu_hash(pat, P, P);
            lib.insert(hash[0][0]);
            turn(pat, P, P);
            calcu_hash(pat, P, P);
            lib.insert(hash[0][0]);
            reverse(pat, P, P);
        }
        calcu_hash(G, H, W);
        int ans = 0;
        for(int i = 0; i + P <= H; ++i)
            for(int j = 0; j + P <= W; ++j)
                if(lib.find(hash[i][j]) != lib.end())
                    ++ans;
        printf("%d\n", ans);
        lib.clear();
    }
    return 0;
}


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

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

    int base = 1;
    rep(i, d) {
        base *= 100;
    };

    if (n < 100) {
        cout << n * base << endl;
    } else {
        cout << 101 * base << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f[64]={1};
int main()
{
	long long n,m,ans=0;
	cin>>n>>m;
	if(m==n)cout<<m<<endl;
	else {
	if(n%2==1){
	ans=n;n++;
	if((m-n+1)%2)ans^=m;
	if(((m-n+1)/2)%2==0)cout<<ans<<endl;
	else cout<<(ans^1)<<endl;}
	else 
	{if((m-n+1)%2)ans^=m;
	if(((m-n+1)/2)%2==0)cout<<ans<<endl;
	else cout<<(ans^1)<<endl;}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>?): Unit {
    while (true) {
        val str = readLine()!!
        if (str == ".") return
        val stack = Stack<Char>()
        var valid = true
        loop@for (c in str){
            when(c){
                '(' -> stack.push(c)
                '[' -> stack.push(c)
                ')' -> {
                    if (stack.isEmpty() || stack.pop() != '(') {
                        valid = false
                        break@loop
                    }
                }
                ']' -> {
                    if (stack.isEmpty() || stack.pop() != '[') {
                        valid = false
                        break@loop
                    }
                }
            }
        }
        println(
                if (valid && stack.isEmpty()) "yes" else "no"
        )
    }
}


Measured memory_bytes: 34508
H,W = map(int, raw_input().split())
A = [list(raw_input()) for _ in range(H)]

x,y = 0,0
while (x!=W-1 or y!=H-1):
    A[y][x] = "."
    r = x<W-1 and A[y][x+1]=="#"
    d = y<H-1 and A[y+1][x]=="#"

    if int(r)+int(d)!=1:
        print "Impossible"
        exit(0)
    if r:
        x += 1
    if d:
        y += 1

if sum(a.count("#") for a in A)!=1:
    print "Impossible"
    exit(0)
print "Possible"


Measured memory_bytes: 2692
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int len1=s1.size();
	int len2=s2.size();
	int flag=0;
	//cout<<len1<<" "<<len2<<endl;
	if(len1>len2)
	{
		cout<<"GREATER"<<endl;
	}
	else if(len1<len2)
	{
		cout<<"LESS"<<endl;
	}
	else
	{
		for(int i=0;i<len1;i++)
		{
			if(s1[i]>s2[i])
			{
				cout<<"GREATER"<<endl;
				break;
			}
			else if(s1[i]<s2[i])
			{
				cout<<"LESS"<<endl;
				break;
			}
			else
			{
				flag=1;
			}
		}
		if(flag==1)
		{
			cout<<"EQUAL"<<endl;
		}
	}
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	int x = 0, a = 1;
	for (int i = 0; i < s.length(); i++) {
		if (a || s[i] != s[i - 1])
			a = 0;
		else a = 1, x++, i++;
	}
	cout << s.length() - x << endl;
	return 0;
}


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

int main()
{
    int n,m,sum=0,x,y,sum1;;
    cin>>n;
    int a[n];
    for(int i=0 ; i<n ; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }

    cin>>m;
    int b[m];

    for(int i=0 ; i<m ; i++)
    {
        sum1=sum;
        cin>>x;
        cin>>y;
        sum1=sum-a[x-1]+y;
        b[i]=sum1;

    }
     for(int i=0 ; i<m ; i++)
    {
         cout <<b[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
S = 3
A = [list(map(int,input().split())) for i in range(S)]
N = int(input())
b = [int(input()) for i in range(N)]

def bingo():
    tA = A
    for i in range(S):
        for j in range(S):
            if(tA[i][j] in b):
                tA[i][j] = True
            else:
                tA[i][j] = False

    TA = list(zip(*tA))
    for i in range(S):
        if(tA[i].count(True)==S):return True
        if(TA[i].count(True)==S):return True
    
    if([tA[i][i] for i in range(S)].count(True)==S): return True
    if([tA[i][S-i-1] for i in range(S)].count(True)==S): return True
    return False

if(bingo()):
    print("Yes")
else:
    print("No")

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back
#define sec second
#define fir first


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//template<class T>auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */


struct cumsum1d{
    int n;
    vector<int> arr;

    cumsum1d(int len){
        n = len;
        rep(i,0,n) arr.push_back(0);
    }

    void init(vector<int> vec){
        arr = vec;
        n = arr.size();
    }

    void add(int a, int b, int val = 1){
        arr[a] += val;
        if(b + 1 < n) arr[b + 1] -= val;
    }

    void build(){
        rep(i,1,n) arr[i] += arr[i-1];
    }

    int query(int from, int to){
        int ret = arr[to];
        if(from) ret -= arr[from - 1];
        return ret;
    }

};

int a, b, c, d;
bool cnt(int n){
    if(a == n or b == n or c == n or d == n) return true;
    else return false;

}

signed main(){


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

    

    cin >> a >> b >> c >> d;

    if(cnt(1) && cnt(4) && cnt(7) && cnt(9)){
        print("YES");
    }else{
        print("NO");
    }


    




    

    



    


    

}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
using namespace std;




int main() {

	int n,k;
	cin >> n>>k;
	if (k == 1)cout << 0 << endl;
	else cout << n - k << endl;
	return 0;
}


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

#define pb(x) push_back(x);
#define in(y) insert(y);
#define tt(t) while(t--)
#define itr ::iterator it;
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define si set<int>                      
#define msi map<string, int>
#define new cout<<endl
#define ff(n) for(int i=0;i<n;i++)
#define all(v) sort(v.begin(),v.end())

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    ff(n) cin>>a[i];
    
    long long int sum=0;
    ff(n){
    	if(a[i]%2!=0) {++sum;}
    }
    	
    if(sum%2!=0) cout<<"NO\n";
    else cout<<"YES\n";
    
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
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 int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


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

    string aa,bb;
    aa = to_string(a);
    bb = to_string(b);
    string as,bs;
    REP(i,a){
        as += bb;
    }
    REP(i,b){
        bs += aa;
    }

    cout << min(as,bs) <<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    char pre = '-';
    int cnt;

    cin >> s;

    for (int i = 0; i < 4; i++) {
        if (pre == s[i]) {
            cnt++;
        }
        else {
            cnt = 1;
            pre = s[i];
        }
        if (cnt > 2) {
            cout << "Yes" << endl;
            return (0);
        }
    }

    cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
//  freopen("test.in","r",stdin);
//  freopen("test.out","w",stdout);
	long long n;
	int m0,number=0;
	cin>>n>>m0;
	int friends[n];
	for(int i=0;i<n;i++){
		cin>>friends[i];
		if(friends[i]>=m0){
			number++;
		}
	}
	cout<<number;
	
    return 0;
}


Measured memory_bytes: 640