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

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1 ;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		string s; cin >> s;
		int l,r;  bool okA = false;
		for(int i=0;i<int(s.length()); i++){
			if(s[i] == 'A' && !okA){
				l = i; 
				okA = true;
			}
			if(s[i] == 'Z' && okA){
				r = i; 
			}
		}
		cout << r - l + 1 << endl;
				
	}
	return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  string s;
  cin >> s;
  if (s[0] != s[1] && s[0] != s[2] && s[1] != s[2]) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        System.out.print(a>b?b+" ":a+" ");
        System.out.println(a+b<n?0:a+b-n);

    }

}

Measured memory_bytes: 23508
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll ans=0;
  int A,B;
  cin >> A >> B;
  if(A*B%2==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
char str[6]={0};
int main()
{
	int len,i,cnt=0;
	scanf("%s",str);
	len=strlen(str);
	for(i=0;i<len;i++)
	{
		if(str[i]=='2')
		{
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
from collections import *
N, K, L = map(int,input().split())

def f(m):
    *a, = range(N)
    def g(i):
        if a[i] == i:
            return i
        a[i] = g(a[i])
        return a[i]
    for _ in range(m):
        p, q = map(int,input().split())
        a[g(q-1)] = g(p-1)
    return g

x, y = f(K), f(L)
c = Counter((x(i),y(i)) for i in range(N))
print(*((c[x(i),y(i)]) for i in range(N)))


Measured memory_bytes: 55644
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int c=0;
  vector<int> cl(N);
  vector<int> cr(N);
  for(int i=0; i<N-1; i++){
    cl[i+1] = cl[i];
    if(S.substr(i,2)=="AC"){
      c++;
      cl[i+1]++;
    }
  } 
  for(int i=N-1; i>0; i--){
    cr[i-1] = cr[i];
    if(S.substr(i-1,2)=="AC"){
      cr[i-1]++;
    }
  } 
  for(int i=0; i<Q; i++){
    int li, ri;
    cin >> li >> ri;
    cout << c-cl[li-1]-cr[ri-1] << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  
  double sum = 0;
  int Lmax = 0;
  for (int i = 0; i < N; i++) {
    sum += data.at(i);
    Lmax = max(data.at(i), Lmax);
  }

  if (Lmax < sum / 2 ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main()
{ int a,b,i,j;
cin>>a>>b;
char c[a][b+1];
for(i=0; i<a; i++)
cin>>c[i];

for(i=0; i<a+2; i++)
{
for(j=0; j<b+2; j++)
{
if(i==0 || i==a+1)
cout<<"#";
}
if(i==0 || i==a+1)
cout<<endl;
if(i>0 && i<a+1)
cout<<"#"<<c[i-1]<<"#"<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<ll>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<ll>())
#define init(a)  memset((a),0,sizeof(a))
#define pi pair<int,int>
#define pb push_back
#define pl pair<ll,ll>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
long double EPS = 1e-9;

bool chk(int i,int j,int n,int m){
    if(i<0||(j<0)||(i>=n)||(j>=m))return false;
    return true;
}



int main()
{
    FIO;
    ll n,t,x,y,m,s1,s2,d1,d2,w;
    cin>>n>>m>>s1>>s2>>d1>>d2;
    s1--,s2--,d1--,d2--;
    string s[n];int dis[n][m],vis[n][m];
    rep(i,0,n){
        cin>>s[i];
    }
    rep(i,0,n){
        rep(j,0,m){dis[i][j]=mod;vis[i][j]=0;}
    }
    deque<pi> q;
    dis[s1][s2]=0;q.pb({s1,s2});
    while(!q.empty()){
        int a=q.begin()->first;int b=q.begin()->second;
        q.erase(q.begin());
        //cout<<a<<" "<<b<<" ";
        if(vis[a][b])continue;
        vis[a][b]=1;
        for(int i=(a-2);i<=(a+2);i++){
            for(int j=(b-2);j<=(b+2);j++){
                if(chk(i,j,n,m)&&(s[i][j]=='.')){
                    if(abs(a-i)+abs(b-j)<=1){w=0;}
                    else w=1;
                    if(dis[a][b]+w<dis[i][j]){
                        dis[i][j]=dis[a][b]+w;
                        if(w==1)q.push_back({i,j});
                        else q.push_front({i,j});
                    }
                }
            }
        }
    }
    if(dis[d1][d2]==mod){cout<<-1;}
    else cout<<dis[d1][d2];
    return 0;
}

Measured memory_bytes: 12548
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> A(N);
    for(auto& x: A) cin >> x;

    ll ans = 1e10;
    for(int i=0; i<N; i++){
        vector<ll> vec;
        priority_queue<ll, vector<ll>, greater<ll> > tmp;
        for(int j=0; j<N; j++){
            if(A[j] >= A[i]) tmp.push(A[j]);
            if(A[j] < A[i] || j == N-1){
                while(!tmp.empty()){
                    if(tmp.size() >= K) vec.push_back(tmp.top());
                    // cout << tmp.top() << " ";
                    tmp.pop();
                }
            }
        }

        if(vec.size() < Q) continue;
        sort(vec.begin(), vec.end());
        ans = min(ans, vec[Q-1] - A[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

constexpr size_t sz{288621};
int HM[sz+2],*END=HM+sz;
bool insert(int a){
    int *p=HM+a%sz;
    while(*p){
        if(*p==a) return true;
        if(++p==END) p=HM;
    }
    *p=a;
    return false;
}

int main(){
    int n{},a,c;
    while((c=getchar_unlocked()-'0')>=0) n*=10,n+=c;
    fr(i,n){
        a=0;
        while((c=getchar_unlocked()-'0')>=0) a*=10,a+=c;
        if(insert(a)){
            putchar_unlocked('N');
            putchar_unlocked('O');
            putchar_unlocked('\n');
            return 0;
        }
    }
    putchar_unlocked('Y');
    putchar_unlocked('E');
    putchar_unlocked('S');
    putchar_unlocked('\n');
}


Measured memory_bytes: 1408
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N, M;
  scanf("%d", &N);
  std::map<std::string, int> mp;
  std::string S;
  for (int i=0; i<N; i++){
    std::cin >> S;
    mp[S]++;
  }
  scanf("%d", &M);
  for (int i=0; i<M; i++){
    std::cin >> S;
    mp[S]--;
  }
  int ans = 0;
  for (auto &entry: mp){
    ans = std::max(ans, entry.second);
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

vector<string> vec = {"SUN", "MON", "TUE", "WED", "THU",
 "FRI","SAT"};

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

  string s;
  cin >> s;

  int pos = 0;
  for(int i=0;i<sz(vec);i++){
    if(vec[i] == s){
      pos = i;
      break;
    }
  }
  pos++;
  int ans = 1;
  if(pos == sz(vec)) pos = 0;

  while(pos != 0){
    pos++;
    ans++;
    if(pos == sz(vec)) pos = 0;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int N=16,M=1<<15,mo=1e9+7;

typedef long long LL;

int n,m,T,f[M],g[N][M],cnt[N][M],p[M];

bool bz[N][M],ok[M];

int main()
{
	scanf("%d%d",&n,&m); T=1<<n;
	p[0]=1;
	for (int i=1;i<=n;i++) p[i]=p[i-1]*2;
	for (int i=0,x,y;i<m;i++)
	{
		scanf("%d%d",&x,&y);
		bz[x][1<<y-1]=1;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<T;j++)
		{
			int k=j&-j;
			cnt[i][j]=cnt[i][j^k]+bz[i][k]; g[i][j]=p[cnt[i][j]]-1;
		}
	}
	for (int i=0;i<T;i++) ok[i]=(((1&i)>0)==((2&i)>0));
	f[0]=1;
	for (int i=1;i<T;i++) if (ok[i])
	{
		f[i]=1;
		for (int j=(i-1)&i;j;j=(j-1)&i) if (ok[j])
		{
			int k=i^j,s=f[k];
			for (int x=0;x<n;x++) if (((1<<x)&k)>0) s=(LL)s*g[x+1][j]%mo;
			else if (((1<<x)&j)>0) s=(LL)s*p[cnt[x+1][k]]%mo;
			f[i]=(f[i]+s)%mo;
		}
	}
	int ans=1;
	for (int i=0;i<m;i++) ans=ans*2%mo;
	ans=(ans-f[T-1]+mo)%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int[] ans = new int[N];
		for(int i = 0;i < N;i++) {
			int a = scn.nextInt()-1;
			ans[a] = i+1;
		}
		Printer.printArrayLine(ans);
	}

}
class Printer{
	static void printArrayLine(int[] a) {
		int N = a.length;
		for(int i = 0;i < N;i++) {
			System.out.print(a[i] + ((i==N-1)?"\n":" "));
		}
	}

	static void printMatrix(int[][] a) {
		int N = a.length;
		int M = a[0].length;
		for(int i = 0;i < N;i++) {
			printArrayLine(a[i]);
		}
	}
}

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

Anega = [a for a in A if a<=0]
Aposi = [a for a in A if a>0]

if Anega and Aposi:
  print(sum(Aposi)-sum(Anega))
  temp = Anega[-1]
  for a in Aposi[:-1]:
    print(*(temp,a))
    temp = temp-a
  print(*(Aposi[-1],temp))
  temp = Aposi[-1]-temp
  for a in Anega[:-1]:
    print(*(temp,a))
    temp = temp-a

elif Aposi:
  print(sum(A[1:]) - A[0])
  a = A[0]
  for i in range(1,N-1):
    print(*(a, A[i]))
    a = a-A[i]
  print(*(A[-1],a))

else:
  print(A[-1] - sum(A[:-1]))
  temp = A[-1]
  for a in A[:-1]:
    print(*(temp,a))
    temp = temp-a

Measured memory_bytes: 14324
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
	IOS;
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	ll k = n * (n + 1) / 2;
	ll l = sum / k;
	if (sum % k) {
		dump("NO"); return 0;
	}
	vector<ll> d(n);
	d[0] = a[0] - a[n - 1] - l;
	REP(i, n - 1) {
		d[i + 1] = a[i + 1] - a[i] - l;
	}
	ll cnt = 0;
	bool ans = true;
	REP(i, n) {
		d[i] *= -1;
		if (d[i] < 0 || d[i] % n)ans = false;
		cnt += d[i] / n;
	}
	if (cnt != l)ans = false;
	dump(ans ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 1000000;
ll mod = INF;

string s;
string head;
string tail;
int Q;
int d=0;

int main(){
    
    cin >> s;
    cin >> Q;
    rep(i,Q){
        int q;
        cin >> q;
        if(q==1){
            d=(d+1)%2;
        }else if(q==2){
            int f;
            char t;
            cin >> f>>t;
            if((d+f)%2==0){
                tail=tail+t;
            }else{
                head=t+head;
            }
        }
    }
    s=head+s+tail;
    if(d==0){
        cout << s<<endl;
    }else{
        int n=s.size();
        rep(i,n){
            cout << s[n-1-i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4464
#include<stdio.h>
int main(void)
{	
	int n1,n2;
    int wa,sa,se,max;

	scanf("%d",&n1);
	scanf("%d",&n2);

	wa=n1+n2, sa=n1-n2, se=n1*n2;

	max=wa;
	if(sa>max)max=sa;
	if(se>max)max=se;
	
	printf("%d",max);


	return(0);
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r;
string s;

// <------------- Implement Functions Here ----------> //

  


// <------------- Start of main() -------------------> //

void MAIN() {
	s = "APPROVED";
	cin>>n;
	for(ll i=0;i<n;i++) {
		cin>>x;
		if(x%2==0 && (x%3 && x%5)) s = "DENIED";
	}
	cout<<s;
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 13008
from itertools import product

n = int(input())
A = list(map(int, input().split()))

count = 0
for C in product((-1, 0, 1), repeat=n):
  total = 1
  for a, c in zip(A, C):
    total *= (a + c)
  if total % 2 == 0:
    count += 1
print(count)

Measured memory_bytes: 9116
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scanf("%d", &a) //10
	fmt.Scanf("%d", &b) //2
	fmt.Scanf("%d", &c) //1
	fmt.Scanf("%d", &x)
	x /= 50
	cnt := 0
	for i := 0; i <= c; i++ {
		if x-i < 0 {
			break
		}
		for j := 0; j <= b; j++ {
			if x-i-j*2 < 0 {
				break
			}
			for k := 0; k <= a; k++ {
				res := x - i - j*2 - k*10
				if res < 0 {
					break
				}
				if res == 0 {
					cnt++
					break
				}
			}
		}
	}
	fmt.Printf("%d", cnt)
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline bool is_lower(const char c) {
    return 'a' <= c && c <= 'z';
}

bool judge(str &s) {
    if(s[0] != 'A') return false;
    str ss = s.substr(2, s.length() - 2 - 1);
    if(count(ALL(ss), 'C') != 1) return false;
    FOR(i, 2, s.length()) {
        if(s[i] != 'C' && !is_lower(s[i])) return false;
    }
    return is_lower(s[1]);
}

int main() {
    str s;
    cin >> s;
    cout << (judge(s) ? "AC" : "WA") << "\n";

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
 
r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')
 
ans = r_cnt * g_cnt * b_cnt
 
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
 
print(ans)

Measured memory_bytes: 9208
#include <stdio.h>

int main() {
	int m, d;
	int cnt = 0, i, j;
	scanf("%d", &m);
	scanf("%d", &d);

	for (i = 4; i <= m; i++) {
		for (j = 22; j <= d; j++) {
			if ((j/10) > 1 && (j%10) > 1) {
				if ((j / 10) * (j % 10) == i) {
					cnt++;
				}
			}
		}
	}

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

	return 0;
}

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

int main(){
    int A, B;
    string S;
    cin >> A >> B;
    cin >> S;

    if(S[A] != '-'){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<A; i++){
        if('0' <= S[i] && S[i] <= '9'){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i=A+1; i<A+B+1; i++){
        if('0' <= S[i] && S[i] <= '9'){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n, t;
  cin >> n >> t;
  unsigned long long p_min = 10000000000;
  unsigned long long p_max = 0;
  int max = 0;
  int ans = 1;
  for(int i=0;i<n;i++) {
      unsigned long long  p;
      cin >>p;
      if (p < p_min) {
          p_min = p;
      }

      unsigned long long profit;
      profit = p - p_min;
      if (p_max < profit) {
          p_max = profit;
          ans = 1;
      } else if (p_max == profit) {
          ans++;
      }

    //   cout << "profit" << profit << "pmax " << p_max << "pmin" << p_min << endl;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{

    void solve(){
        LL x,y,ans=0;
        cin >> x >> y;
        while(x<=y){
            x*=2;
            ans++;
        }
        cout << ans <<"\n";
    }
};

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

    Problem p;
    p.solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define dpb push_back
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9;

#define int long long
signed main(){
	int h, w;
	scanf("%lld%lld", &h, &w);
	int ans = 0;
	if(h == 1 || w == 1){
		ans = min((int)2, h*w);
		if(h*w == 1)ans = 0;
	}else if(h == 2 || w == 2){
		ans = h*w;
	}else{
		ans = 2*h+2*(w-2);
	}
	printf("%lld\n", h*w-ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int H,W,i,j,ans=0;
	for(;;){
		cin>>H>>W;
		if(H==0&&W==0){
		break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				ans=(i+j)%2;
				if(ans==0){
					cout<<"#";
				}else{
					cout<<".";
				}
			}
			cout<<endl;
		}
			cout<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
    int N;
    int sum = 0;
    cin >> N;
    std::vector<int> v(N);
    std::vector<int> c(N);
    std::vector<int> rem(N);

for(int i = 0; i < N; ++i)
    cin >> v[i];
for(int i = 0; i < N; ++i)
    cin >> c[i];
for(int i = 0; i < N; ++i){
    rem[i] = v[i]- c[i];
    if(rem[i] > 0)
    sum += rem[i];
}

std::cout << sum << endl;

 return 0;    
}

Measured memory_bytes: 256
def main():
    N = int(input())
    lst = []
    for _ in range(N):
        name, time = input().split()
        lst.append((name, int(time)))
    x = input()

    total = 0
    for n, t in reversed(lst):
        if n == x:
            break
        total += t

    print(total)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
 
using namespace std;

int n,m,f[422][422]; 
char s[21][21];

int turn(int x,int y)
{
	return (x-1)*m+y;
}

int main()
{
//	freopen("data.txt","r",stdin);
//	freopen("my.txt","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%s",s[i]+1);
	int t=n*m;
	for(int i=1;i<=t;++i)
		for(int j=1;j<=t;++j)
			f[i][j]=1e9;
	int u,v;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			u=turn(i,j);
			if(s[i][j]=='#')
			{
				if(u>m) f[u][u-m]=1e9;
				f[u][u+m]=f[u][u]=f[u][u-1]=f[u][u+1]=1e9;
				continue;
			}
			f[u][u]=0;
			if(i>1 && s[i-1][j]=='.') f[u][u-m]=1;
			if(i<n && s[i+1][j]=='.') f[u][u+m]=1;
			if(j>1 && s[i][j-1]=='.') f[u][u-1]=1;
			if(j<m && s[i][j+1]=='.') f[u][u+1]=1;
		}
	for(int k=1;k<=t;++k)
		for(int i=1;i<=t;++i)
			for(int j=1;j<=t;++j)
				if(f[i][k]<1e9 && f[k][j]<1e9) f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	int ans=0;
	for(int i=1;i<=t;++i)
		for(int j=1;j<=t;++j)
			if(f[i][j]<1e9) ans=max(ans,f[i][j]);
	printf("%d",ans);
}


Measured memory_bytes: 768
fun main(args: Array<String>) {
    val (A, B) = readInputLine().split(" ").map { it.toLong() }

    println(A * B / gcd(A, B))
}

fun readInputLine(): String {
    return readLine()!!
}

fun gcd(a: Long, b: Long): Long {
    if (b > a) {
        return gcd(b, a)
    }
    if (b == 0L) {
        return a
    }
    return gcd(b, a % b)
}


Measured memory_bytes: 37940
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  unordered_set<char> buf;
  string s,t;
  cin >> s >> t;
  for(int i=0;i<s.size();++i){ buf.insert(s[i]); }
  for(char ti : t){
    if(buf.find(ti)==buf.end()) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<vector<ll>> pos(256);
  rep(i, s.size()) pos[s[i]].push_back(i);
  rep(i, 256) sort(all(pos[i]));
  ll ans = 0;
  ll curpos = -1;
  for(char ti : t){
    //auto it = lower_bound(all(pos[ti]), curpos);
    auto it = upper_bound(all(pos[ti]), curpos);
    if(it==pos[ti].end()){
      ans += s.size() - curpos + pos[ti][0];
      curpos = pos[ti][0];
      //nback++; curpos = 0; it = upper_bound(all(pos[ti]), curpos);
    }
    else {
      ans += *it - curpos;
      curpos = *it;
    }
      
  }
  cout << ans << endl;
  return 0;
}


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

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            if (S.Length <= K)
                Console.WriteLine(S);
            else
                Console.WriteLine(S.Substring(0, K) + "...");

        }
    }
}


Measured memory_bytes: 27480
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;



int main(){
    string s;cin >> s;
    int a=0,b=0;
    for (int i = 0; i < s.length(); i++) {
        if(s[i]=='0') a++;
        else b++;
    }
    cout << 2*min(a,b) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int A[3];
    for(int i = 0; i < 3; ++i)
        cin >> A[i];
    cout << (A[0] + A[1] + A[2] < 22 ? "win" : "bust") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  double x[n];
  char u[n][3];
  double sum=0;
  for (int i=0;i<n;i++){
    scanf("%lf %s",&x[i],&u[i]);
    if (!strcmp(u[i],"JPY")){
      sum+=x[i];
    }
    if (!strcmp(u[i],"BTC")){
      sum+=x[i]*380000.0;
    }
  }
  printf("%lf\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
main () {
    int n; cin >> n;
    int a[4] = {};

    while (n--) {
        string temp;
        cin >> temp;
        if (temp == "AC")
            a[0]++;
        else if (temp == "WA")
            a[1]++;
        else if (temp == "TLE")
            a[2]++;
        else 
            a[3]++;
    }

    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3];
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using graph = vector<vector<int>>;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
 
 
int main() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  int count=0;
  for(int i=n-1; i>=2; i--){
    for(int j=i-1; j>=1; j--){
      for(int k=j-1; k>=0; k--){
        if(v[i]>=v[j]+v[k]){break;}
        else{count++;}
      }
    }
  }
  cout<<count;
}

Measured memory_bytes: 3636
n, k = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)
p.unshift(0)

1.step(n) do |i|
  p[i] += p[i - 1]
end

res = -1

k.step(n) do |i|
  if p[i] - p[i - k] > res
    res = p[i] - p[i - k]
  end
end

puts "%.7f" % [(res + k) / 2.0]

Measured memory_bytes: 28684
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

while True:
    a = list(map(int, input().split()))
    if a.count(0) == 6:
        break
    x = a[0] % a[1]
    ix = 1
    while x != 1:
        x = a[0] * x % a[1]
        ix += 1
    y = a[2] % a[3]
    iy = 1
    while y != 1:
        y = a[2] * y % a[3]
        iy += 1
    z = a[4] % a[5]
    iz = 1
    while z != 1:
        z = a[4] * z % a[5]
        iz += 1
    ixy = ix * iy // gcd(ix, iy)
    print(ixy * iz // gcd(ixy, iz))

Measured memory_bytes: 7712
# Problem E - Divisible Substring

from collections import Counter

# input
N, P = map(int, input().split())
S = list(input())

# count
if P==2 or P==5:
    ans = 0
    for i in range(N-1, -1, -1):
        s = int(S[i])
        if s%P==0:
            ans += i + 1
    # output
    print(ans)
else:
    p_nums = [0]*(N+1)
    s = 0
    for i in range(N-1, -1, -1):
        s = int(S[i]) * pow(10, N - i - 1, P) + s
        p_nums[N - i] = s%P
    p_counter = [0]*P
    for i in range(N+1):
        p_counter[p_nums[i]] += 1
    ans = 0
    for i in range(P):
        ans += p_counter[i] * (p_counter[i] - 1) // 2
    print(ans)


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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int H, W;
	
	cin >> H >> W;
	
	vector<string> C(H);
	
	for(int i=0; i<H; i++)
		cin >> C.at(i);
	
	for(int i=0; i<H; i++){
		cout << C.at(i) << endl << C.at(i) << endl;
	}
	
	return 0;
}

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

using namespace std;

#define fi first
#define se second

int main()
{
    int L, R, M=2000000000, sk;
    cin >> L >> R;
    sk = R - L;
    L %= 2019;
    R %= 2019;
    if (sk >= 2019)
    {
        L = 0;
        R = 2019;
    }
    if (L > R)
    {
        swap(L, R);
    }
    for (int i = L; i <= R; i++)
    {
        for (int y = L; y < i; y++)
        {
            M = min(M, (i*y)%2019);
        }
    }
    cout << M;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    string s;
    cin >> n >> s;

    ll cntR = 0, cntG = 0, cntB = 0;
    rep(i, n) {
        if(s[i] == 'R') {
            cntR++;
        }
        if(s[i] == 'G') {
            cntG++;
        }
        if(s[i] == 'B') {
            cntB++;
        }
    }

    ll ans = cntR*cntG*cntB;
    exrep(i, 0, n-2) {
        exrep(j, i+1, n-1) {
            ll k = 2*j - i;
            if(n <= k) {
                continue;
            }
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                ans--;
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N + 1), B(N);
    for (auto& x : A) cin >> x;
    for (auto& x : B) cin >> x;
    ll res = 0;
    for (int i = 0; i < N; i++) {
      ll rem = B[i];
      ll use1 = min(rem, A[i]);
      res += use1;
      rem -= use1;
      ll use2 = min(rem, A[i + 1]);
      res += use2;
      A[i + 1] -= use2;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    field = []
    for i in range(H):
        input_raw = read_func().strip()
        field.append(input_raw)

    pre_last = -1
    for i in range(H):
        first = -1
        last = -1
        for j in range(W):
            if field[i][j] == '#':
                if first == -1:
                    first = j
                last = j
        if pre_last > first:
            print "Impossible"
            return
        pre_last = last

    pre_last = -1
    for j in range(W):
        first = -1
        last = -1
        for i in range(H):
            if field[i][j] == '#':
                if first == -1:
                    first = j
                last = j
        if pre_last > first:
            print "Impossible"
            return
        pre_last = last

    print "Possible"

if __name__ == '__main__':
    main()

Measured memory_bytes: 3044
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define pb push_back
#define endl '\n';
#define sz(s) int(s.size())
#define Ceil(x,y)  ((x+y-1)/y)
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define I64 int
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const ll mod = ll(1e9 + 7);
const double PI = acos(-1.0);
const int N = (int)1e6 * 2;
using namespace std;
void Selim()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll LCM(ll a, ll b) { return a / gcd(a, b)*b; }
//ll Mod(ll x, ll m){ return ((x % m) + m) % m; }
//ll fact(long long  n) { return !n ? 1 : n * fact(n - 1); }
//transform(s.begin(), s.end(), s.begin(), ::tolower);
//palindrom if(s==string(s.rbegin(),s.rend()))
//memset(arr,0,sizeof arr)
/*
*********************************************************************************************

If you want something you've never had, you must be willing to do something you've never done

*********************************************************************************************
*/
int main()
{
	Selim();
	/*int t;
	cin >> t;
	while (t--){
		ll a, b, mnA, mnB, n;
		cin >> a >> b >> mnA >> mnB >> n;
		ll cur_A = a - mnA, cur_B = b - mnB;
		if (cur_A >= cur_B){
			if (a <= b){
				a -= min(n, cur_A);
				n -= min(n, cur_A);
				b -= min(n, cur_B);
			}
			else{
				b -= min(n, cur_B);
				n -= min(n, cur_B);
				a -= min(n, cur_A);
			}
		}
		else{
			if (b <= a){
				b -= min(n, cur_B);
				n -= min(n, cur_B);
				a -= min(n, cur_A);
			}
			else{
				a -= min(n, cur_A);
				n -= min(n, cur_A);
				b -= min(n, cur_B);
			}
		}
		/*if (cur_A + cur_B <= n){
			cout << mnA*mnB << endl;
			continue;
		}
		ll m = min(n / 2, cur_A);
		n -= m;
		a -= m, b -= min(n, cur_B);
		if (n & 1){

		}
		cout << a*b << endl;
	}*/
	string s;
	cin >> s;
	if (s[sz(s) - 1] == 's')s += "es";
	else s += 's';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3668
/*

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

typedef vector<vector<ll> > matrix;

matrix mul(matrix a, matrix b){
    matrix c;
    c.resize(a.size());
    for (int i = 0; i < c.size(); i++)
        c[i].resize(b[0].size(), 0);
    for (int i = 0; i < c.size(); i++)
        for (int j = 0; j < c[i].size(); j++)
            for (int k = 0; k < b.size(); k++)
                c[i][j] = (c[i][j] + a[i][k] * b[k][j]);
    return c;
}

matrix def;

matrix bpow(matrix a, ll st){
    if (st == 0)
        return def;
    if (st == 1)
        return a;
    matrix b = bpow(a, st >> 1);
    b = mul(b, b);
    if (st & 1)
        b = mul(a, b);
    return b;
}

ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MOD = 1e9 + 993;

ll myrand(){
    ll ZR = (XR * AR + YR * BR + CR) % MOD;
    XR = YR;
    YR = ZR;
    return ZR;
}

ll sqr(ll x){
    return x * x;
}

const ll llinf = 2e18;

const ld EPS = 1e-9;

const int maxn = 1e5 + 100, inf = 1e9 + 100, sq = 300, mod = 1e9 + 9;

int n;

ll a, b;

ll q[maxn];

bool check(ll k){
    ll need = 0;
    for (int i = 0; i < n; i++)
        need += max(0ll, (q[i] - b * k + (a - b) - 1) / (a - b));
    return need <= k;
}

int main()
{
    #ifdef ONPC
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #else
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++)
        cin >> q[i];
    int l = 0, r = 1e9 + 1;
    while (r - l > 1){
        int m = (l + r) / 2;
        if (check(m))
            r = m;
        else
            l = m;
    }
    cout << r;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

o = 0
e = 0
for x in a:
    if x%2==0:
        e += 1
    else:
        o += 1

e += (o//2)
o %= 2

if o==0 and e>0:
    print("YES")
elif o==1 and e==0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 14112
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

typedef long double DOUBLE;
typedef complex<DOUBLE> COMPLEX;
typedef vector<DOUBLE> VD;
typedef vector<COMPLEX> VC;

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int sub(int a, int b) {
    int s = (a-b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}



int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    cin>>n;
    vector<vector<int>> G(n);
    int a, b;
    for (int i = 0; i<n-1; i++)
    {
        cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<int> d(n, -1);
    queue<int> bfs;
    bfs.push(0);
    d[0] = 0;
    while (!bfs.empty())
    {
        int s = bfs.front();
        bfs.pop();
        for (auto it: G[s]) if (d[it]==-1)
        {
            d[it] = d[s]+1;
            bfs.push(it);
        }
    }
    int maxx = -1;
    int idx = -1;
    for (int i = 0; i<n; i++)
    {
        if (d[i]>maxx) {maxx = d[i]; idx = i;}
    }

    d = vector<int>(n, -1);
    bfs.push(idx);
    d[idx] = 0;
    while (!bfs.empty())
    {
        int s = bfs.front();
        bfs.pop();
        for (auto it: G[s]) if (d[it]==-1)
        {
            d[it] = d[s]+1;
            bfs.push(it);
        }
    }
    maxx = -1;
    for (int i = 0; i<n; i++) maxx = max(maxx, d[i]);
    //cout<<maxx<<endl;
    if (maxx%3==1) cout<<"Second";
    else cout<<"First";
    
}

Measured memory_bytes: 14324
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
#+sbcl (declaim (sb-ext:unmuffle-conditions sb-ext:compiler-note))
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(declaim (type (integer 1 200) *k*))
(defvar *k* (read))

;; gcd(a,b,c) = gcd(gcd(a,b),c)

(princ (loop for a from 1 to *k* summing
	     (loop for b from 1 to *k*
		   for z = (gcd a b) summing
		   (loop for c from 1 to *k* summing
			 (gcd z c) fixnum) fixnum) fixnum))


Measured memory_bytes: 24624